
*version 								    		//declare the version and create the do-file
clear all											//clear everything
set more off										//switch off more message

use "C:\Users\ml3237\Dropbox\Climate Survey\Survey data from NORC_Final\afa.dta", clear
	
cd "C:\Users\ml3237\Dropbox\Climate Survey\Survey data from NORC_Final\Michelle output"	//ML computer

global graphs "C:\Users\ml3237\Dropbox\Climate Survey\Stata Programs_ML\Michelle output"
global path "C:\Users\ml3237\Dropbox\Climate Survey\Stata Programs_ML\Michelle output"





*********************************************************************************************************************
**Modify controls and vars of interest
**clin, asstprof, female
**white, asian, minority
**bornoutsideus, liveoutsideus
*********************************************************************************************************************


**define student

gen student=0 if !missing(employment_suppressed)
replace student=1 if employment_suppressed==3 /*23.8% are students, defined over 1628 obs, ie 387 students*/
sum student

label define studesc 0 "Non-Student" 1 "Student"
label values student studesc


**define non-student researcher (including govt agency people)

gen researcher=1 if role==2|role==3|role==4|role==7|role==9|nonaca_occ_w_backcode==1
replace researcher=. if area_research==1



**gen untenured: defined across all non-student researchers

gen untenured=1 if researcher==1 & tenure==2
replace untenured=0 if researcher==1 & (tenure==1 | tenure==3)

gen tenuredML = 1 if untenured==0
replace tenuredML = 0 if untenured==1

label define tendesc 0 "Not Tenured" 1 "Tenured"
label values tenuredML tendesc




**Gen summary variable of role

label define roledesc 1 "PhD Student" 2 "Research Faculty", modify
label define roledesc 3 "Research Staff (Non-academic)" 4 "Clinical Fac & NonResearch Inst", modify

gen roleML = 1 if student==1
replace roleML = 2 if researcher==1 & employer_suppressed==1  /*faculty*/
replace roleML = 3 if researcher==1 & employer_suppressed !=1 /*research staff, non-academic*/
replace roleML = 4 if missing(researcher) & student != 1      /*non-researcher (eg emeritus, lecturer)*/

label values roleML roledesc


**define faculty

gen faculty = 1 if researcher==1 & employer_suppressed==1
replace faculty = 0 if researcher !=1 | employer_suppressed != 1

gen nonfacresearcher = 1 if researcher==1 & employer_suppressed !=1
replace nonfacresearcher = 0 if researcher==0 | employer_suppressed ==1

gen nonresearcher = 1 if missing(researcher) & student != 1 
replace nonresearcher = 0 if !missing(researcher) | student==1


label var faculty "Faculty"
label var nonfacresearcher "Non-faculty Researcher"
label var nonresearcher "Non-researcher"



*drop workplacetype

gen workplacetype = 1 if employer_suppressed==1 /*university*/
replace workplacetype = 2 if nonaca_occ_w_backcode==1 /*govt agency*/
replace workplacetype = 3  if employer_suppressed==2 | nonaca_occ_w_backcode==3 | nonaca_occ_w_backcode==4 /*for-profit co*/

label define workplacedesc 1 "University" 2 "Govt Agency", modify
label define workplacedesc 3 "ForProfit Co", modify
label values workplacetype workplacedesc






**gender and race and ethnicity

gen female=0 if !missing(gender_suppressed)
replace female=1 if gender_suppressed==2 /*defined across 1198 obs, 25.8% are female, ie 310 females*/

label define femaledesc 0 "Male" 1 "Female"
label values female femaledesc


gen genderreverseML = 1 if female==1
replace genderreverseML = 2 if female==0
label define genderdesc 1 "Female" 2 "Male"
label values genderreverseML genderdesc

gen racedata=1 if !missing(race_black_or_african_american) | !missing(race_hispanic_or_latinx) | !missing(race_mid_eastern_or_n_african) | !missing(race_asian_or_asian_american) | !missing(race_other) | !missing(race_white_or_caucasian)

gen black=1 if !missing(racedata) & race_black_or_african_american==1 
replace black=0 if !missing(racedata) & race_black_or_african_american != 1

gen asian=1 if !missing(racedata) & race_asian_or_asian_american==1 
replace asian=0 if !missing(racedata) & race_asian_or_asian_american != 1

gen hispanic=1 if !missing(racedata) & race_hispanic_or_latinx==1 
replace hispanic=0 if !missing(racedata) & race_hispanic_or_latinx != 1

gen mideast=1 if !missing(racedata) & race_mid_eastern_or_n_african==1 
replace mideast=0 if !missing(racedata) & race_mid_eastern_or_n_african != 1

gen other=1 if !missing(racedata) & race_other==1 
replace other=0 if !missing(racedata) & race_other != 1

gen white=1 if !missing(racedata) & race_white_or_caucasian==1 
replace white=0 if !missing(racedata) & race_white_or_caucasian != 1

gen minority = 0 if !missing(racedata)
replace minority = 1 if !missing(racedata) & (race_black_or_african_american==1 | race_hispanic_or_latinx==1 | race_mid_eastern_or_n_african==1 | race_other==1)



**Create a summary race variables

label define racedesc 1 "White" 2 "Asian", modify
label define racedesc 3 "Latinx" 4 "Black" 5 "MidEast" 6 "Other", modify
gen raceML = 1 if white==1
replace raceML = 2 if asian==1
replace raceML = 3 if hispanic==1
replace raceML = 4 if black==1
replace raceML = 5 if mideast==1
replace raceML = 6 if other==1
label values raceML racedesc



**region raised and region now 

tab region_raised /*defined across 1210 obs, 73% born outside of us*/
tab region_now /*defined across 1217 obs, 44% living outside of us*/

gen bornoutsideus=1 if !missing(region_raised)
replace bornoutsideus=0 if region_raised == 6

gen liveoutsideus=1 if !missing(region_now)
replace liveoutsideus=0 if region_now == 6




gen region_nowML = region_now

label define regiondesc 1 "Africa" 2 "Asia", modify
label define regiondesc 3 "Australia" 4 "Europe" 5 "C/S Amer" 6 "US/Can", modify
label values region_nowML regiondesc



**Make dummies out of various variables that are coded 1, 2

gen unsolicited_discussdum = 1 if unsolicited_discuss==2
replace unsolicited_discussdum = 0 if unsolicited_discuss==1
*_crcslbl unsolicited_discussdum unsolicited_discuss
label var unsolicited_discussdum "Approached about job"

gen unsolicited_offerdum = 1 if unsolicited_offer==2
replace unsolicited_offerdum = 0 if unsolicited_offer==1
*_crcslbl unsolicited_offerdum unsolicited_offer
label var unsolicited_offerdum "Unsolicited offer"

gen unsolicited_offerpct = 100 if unsolicited_offer==2
replace unsolicited_offerpct = 0 if unsolicited_offer==1



**Fix reserach variables for graphs

gen area_researchML = area_research

label define areadesc 2 "AsstPrc" 3 "Behavioral", modify
label define areadesc 4 "CorpFin" 5 "FinIntermed" 6 "Household" 7 "Microstruc" 8 "Other" , modify
label values area_researchML areadesc

gen citationsML = citations



label define citdesc 1 "<100" 2 "100-499", modify
label define citdesc 3 "500-999" 4 "1000-2999" 5 "3000-4999" 6 "5000+" 7 "Don't Know" , modify
label values citationsML citdesc


**Generate an alternative variable for res_environ, with shorter labels

gen res_environML = res_environ
tab res_environML

label define resdesc 1 "Teaching School" 2 "Research, below top tier"
label define resdesc 3 "Research, some top tier" 4 "Research, top tier", modify

label values res_environML resdesc




**Pre-covid start project variables

gen newproj_precov = 1     if (researcher==1 | student==1) & (newproj_ay_start_proj_with_s1==1 | newproj_ay_start_proj_with_so==1)
replace newproj_precov = 0 if (researcher==1 | student==1) &  newproj_ay_not_start_new_proj == 1

gen newproj_precov_newperson = 1     if (researcher==1 | student==1) & (!missing(newproj_precov) & newproj_ay_start_proj_with_s1==1)
replace newproj_precov_newperson = 0 if (researcher==1 | student==1) & (!missing(newproj_precov) & missing(newproj_ay_start_proj_with_s1))


**Fix post-covid start project variables

gen newproj_postcov = 1     if (researcher==1 | student==1) & (newproj_cov_start_proj_with_1==1 | newproj_cov_start_proj_with_s==1)
replace newproj_postcov = 0 if (researcher==1 | student==1) &  newproj_cov_not_start_new_proj == 1

gen newproj_postcov_newperson = 1     if (researcher==1 | student==1) & (!missing(newproj_postcov) & newproj_cov_start_proj_with_1==1)
replace newproj_postcov_newperson = 0 if (researcher==1 | student==1) & (!missing(newproj_postcov) & missing(newproj_cov_start_proj_with_1))

sum newproj_precov  newproj_precov_newperson  /*defined across 1227 people, 77% start new proj, 37% start new proj w new person*/
sum newproj_postcov newproj_postcov_newperson /*defined across 1229 people, 71.6% start new proj, 36.7% start new proj w new person*/

gen newproj_precovPct = newproj_precov * 100 
gen newproj_postcovPct = newproj_postcov * 100
gen newproj_precov_newpersonPct = newproj_precov_newperson * 100 
gen newproj_postcov_newpersonPct = newproj_postcov_newperson * 100



**Discrimination variables

gen discrim_pers_dumML = (discrim_personal - 1) * 100
gen discrim_wit_dumML = (discrim_witness - 1) * 100

gen     discrim_authaddress_dumML = 100 if ((discrim_authority==3 | discrim_authority==4 | discrim_authority==5))
replace discrim_authaddress_dumML = 0 if ((discrim_authority==1 | discrim_authority==2  ))

gen     discrim_authaddress_dumMLreg = 100 if ((discrim_authority==3 | discrim_authority==4 | discrim_authority==5))
replace discrim_authaddress_dumMLreg = 0 if ((discrim_authority==1 | discrim_authority==2 | discrim_authority==6))

gen     discrim_authaddress_dumreg = 1 if ((discrim_authority==3 | discrim_authority==4 | discrim_authority==5))
replace discrim_authaddress_dumreg = 0 if ((discrim_authority==1 | discrim_authority==2 | discrim_authority==6))


label define discrimdesc 1 "Gender" 2 "Age"
label define discrimdesc 3 "Race" 4 "Research" 5 "Family" 6 "Politics" 7 "Sex Identity" 8 "Religion" 9 "Disability" , modify

gen discrim_pers_sexML = (discrim_pers_sex - 1) * 100
gen discrim_pers_ageML = (discrim_pers_age - 1) * 100
gen discrim_pers_raceML = (discrim_pers_race - 1) * 100
gen discrim_pers_researchML = (discrim_pers_research - 1) * 100
gen discrim_pers_familyML = (discrim_pers_family - 1) * 100
gen discrim_pers_politicsML = (discrim_pers_politics - 1) * 100
gen discrim_pers_orientationML = (discrim_pers_orientation - 1) * 100
gen discrim_pers_religionML = (discrim_pers_religion - 1) * 100
gen discrim_pers_disabilityML = (discrim_pers_disability - 1) * 100

gen discrim_wit_sexML = (discrim_wit_sex - 1) * 100
gen discrim_wit_ageML = (discrim_wit_age - 1) * 100
gen discrim_wit_raceML = (discrim_wit_race - 1) * 100
gen discrim_wit_researchML = (discrim_wit_research - 1) * 100
gen discrim_wit_familyML = (discrim_wit_family - 1) * 100
gen discrim_wit_politicsML = (discrim_wit_politics - 1) * 100
gen discrim_wit_orientationML = (discrim_wit_orientation - 1) * 100
gen discrim_wit_religionML = (discrim_wit_religion - 1) * 100
gen discrim_wit_disabilityML = (discrim_wit_disability - 1) * 100

label values discrim_pers_dumML discrimdesc
label values discrim_wit_dumML discrimdesc



**Make a topschool dummy (defined across entire population)


gen topschool=0 
replace topschool=1 if res_environ==1 

label define topdesc 1 "Top Research Univs'" 0 "All Other Univs", modify
label values topschool topdesc



**Question asking
**seminar_askq = 1 if ask no questions, 2 if yes/no, 3 if na have never attended 
**seminar_askq_comfort = 1 to 5

gen     QUES_SEM = 1 if seminar_askq==1 /*asks no question*/
replace QUES_SEM = 2 if seminar_askq_comfort==1 /* not at all comfortable*/
replace QUES_SEM = 3 if seminar_askq_comfort==2 /* somewhat uncomfortable*/
replace QUES_SEM = 4 if seminar_askq_comfort==3 /* somewhat comfortable*/
replace QUES_SEM = 5 if seminar_askq_comfort==4 /* very comfortable*/

gen     QUES_CONF = 1 if conf_askq==1 /*asks no question*/
replace QUES_CONF = 2 if conf_askq_comfort==1 /* not at all comfortable*/
replace QUES_CONF = 3 if conf_askq_comfort==2 /* somewhat uncomfortable*/
replace QUES_CONF = 4 if conf_askq_comfort==3 /* somewhat comfortable*/
replace QUES_CONF = 5 if conf_askq_comfort==4 /* very comfortable*/

label define quesdesc 1 "Asks no questions" 2 "Not comfortable"
label define quesdesc 3 "Somewhat uncomfortable" 4 "Somewhat comfortable" 5 "Very comfortable", modify

label values QUES_SEM quesdesc
label values QUES_CONF quesdesc


**Comments received

gen virtualpresent_commentsML = virtualpresent_comments
gen virtualsem_commentsML     = virtualsem_comments
gen virtual_engagedML = virtual_engaged

label define virtualdesc 1 "Considerably fewer" 2 "Somewhat fewer"
label define virtualdesc 3 "About the same" 4 "Somewhat more" 5 "Considerably more" 6 "No virtual presentation", modify
label values virtualpresent_commentsML virtualdesc
label values virtualsem_commentsML virtualdesc

label define engageddesc 1 "Much less" 2 "A bit less"
label define engageddesc 3 "Equally" 4 "A bit more" 5 "Much more" 6 "No virtual presentation", modify
label values virtual_engagedML engageddesc






***Area of Research Topic

gen corpfin=0 if !missing(area_research) & area_research !=8
replace corpfin=1 if area_research==4

gen asstprc=0 if !missing(area_research) & area_research !=8
replace asstprc=1 if area_research==2


**Childduties during covid and pre-covid

gen     childdutiespre = 0 if !missing(children_under_18)
replace childdutiespre = childcare_precov if !missing(childcare_precov) & !missing(children_under_18)

gen     childdutiescov = 0 if !missing(children_under_18)
replace childdutiescov = childcare_duringcov if !missing(childcare_duringcov) & !missing(children_under_18)

gen     highchildcare_pre=0 if !missing(childcare_precov)
replace highchildcare_pre=1 if !missing(childcare_precov) & childcare_precov>=5

gen     highchildcare_cov=0 if !missing(childcare_duringcov)
replace highchildcare_cov=1 if !missing(childcare_duringcov) & childcare_duringcov>=5

gen     highchildcare_prePct=0 if !missing(childcare_precov)
replace highchildcare_prePct=100 if !missing(childcare_precov) & childcare_precov>=5

gen     highchildcare_covPct=0 if !missing(childcare_duringcov)
replace highchildcare_covPct=100 if !missing(childcare_duringcov) & childcare_duringcov>=5

gen avoid_notapplyML = (avoid_notapply-1)*100
gen avoid_leftpostML = (avoid_leftpost-1)*100
gen avoid_notresearchML = (avoid_notresearch-1)*100



**Time diaries variables

**fix time diary variables***************************************************************************************************************

foreach d in  time_class_student  time_acawork_student time_employ_student time_research_student  time_childcare_student  time_social_student  time_relax_student  time_exercise_student time_hobbies_student  time_sleep_student {
	gen `d'2 = `d' - 1
}


foreach d in time_sleep time_research time_childcare  time_teaching time_teachingact time_email  time_mtg time_social time_relax time_service time_exercise time_hobbies time_consult time_external time_volunteer {
	gen `d'2 = `d' - 1
}


foreach d in time_mtg_non_academic time_email_non_academic time_research_non_academic time_service_non_academic time_consult_non_academic time_external_non_academic time_childcare_non_academic time_social_non_academic time_relax_non_academic ///
             time_volunteer_non_academic  time_exercise_non_academic time_hobbies_non_academic time_sleep_non_academic  {
	gen `d'2 = `d' - 1
}

egen time_nonwork_nonacademic = rowtotal(time_social_non_academic2 time_relax_non_academic2   time_volunteer_non_academic2  time_exercise_non_academic2  time_hobbies_non_academic2) if !missing(time_social_non_academic2) | !missing(time_relax_non_academic2) | !missing(time_volunteer_non_academic2) | !missing(time_exercise_non_academic2) | !missing(time_hobbies_non_academic2)

gen time_childcare_non_acad = time_childcare_non_academic


				   
gen time_teachall2 = time_teaching2 + time_teachingact2
gen time_emailmtg2 = time_email2 + time_mtg2
gen time_consultext2 = time_consult2 + time_external2
gen time_nonwork2 = time_social2 + time_relax +  time_exercise2 + time_hobbies2 +  time_volunteer2
gen time_nonwork3 = time_social2 + time_relax +  time_exercise2 + time_hobbies2


**Change in time use during Covid - faculty*/

*drop lesschgtime_teach lesschgtime_teachact lesschgtime_research lesschgtime_childcare morechgtime_teach morechgtime_teachact morechgtime_research morechgtime_childcare
foreach d in chgtime_teach chgtime_teachact chgtime_research chgtime_childcare chgtime_mtg chgtime_email chgtime_consult chgtime_service chgtime_social chgtime_relax chgtime_exercise chgtime_hobbies chgtime_sleep chgtime_external  {
	gen less`d' = 100 if `d' == 1
	replace less`d' = 0 if `d' == 2 | `d'==3

	gen more`d' = 100 if `d' == 3
	replace more`d' = 0 if `d' == 1 | `d'==2

	}
	
	
**Change in time use during Covid - students*/

*drop lesschgtime_teach lesschgtime_teachact lesschgtime_research lesschgtime_childcare morechgtime_teach morechgtime_teachact morechgtime_research morechgtime_childcare
foreach d in chgtime_class_student chgtime_acawork_student chgtime_employ_student chgtime_research_student chgtime_childcare_student chgtime_social_student chgtime_relax_student chgtime_exercise_student chgtime_hobbies_student chgtime_sleep_student  {
	gen less`d' = 100 if `d' == 1
	replace less`d' = 0 if `d' == 2 | `d'==3

	gen more`d' = 100 if `d' == 3
	replace more`d' = 0 if `d' == 1 | `d'==2

	}

	
	
	
**Change in time use during Covid - nonacademics*/

*drop lesschgtime_teach lesschgtime_teachact lesschgtime_research lesschgtime_childcare morechgtime_teach morechgtime_teachact morechgtime_research morechgtime_childcare
foreach d in chgtime_mtg_non_academic chgtime_email_non_academic chgtime_research_non_academic chgtime_service_non_academic chgtime_consult_non_academic chgtime_external_non_academic chgtime_childcare_non_academic chgtime_social_non_academic         chgtime_relax_non_academic chgtime_volunteer_non_academic chgtime_exercise_non_academic chgtime_hobbies_non_academic chgtime_sleep_non_academic  {
	gen l`d' = 100 if `d' == 1
	replace l`d' = 0 if `d' == 2 | `d'==3

	gen m`d' = 100 if `d' == 3
	replace m`d' = 0 if `d' == 1 | `d'==2

	}	
	

**caregiver

gen caregiver = 1 if chldcare_precov_hlp_respondent==1
replace caregiver = 0 if children_supervision==2 & chldcare_precov_hlp_respondent !=1 & (!missing(chldcare_precov_hlp_caregiver) | !missing(chldcare_precov_hlp_oncampus) | !missing(chldcare_precov_hlp_offcampus) | !missing(chldcare_precov_hlp_partner) | !missing(chldcare_precov_hlp_other ))
sum caregiver

gen partnercaregiver = 1 if chldcare_precov_hlp_partner==1
replace partnercaregiver = 0 if children_supervision==2 & chldcare_precov_hlp_partner !=1 & (!missing(chldcare_precov_hlp_caregiver) | !missing(chldcare_precov_hlp_oncampus) | !missing(chldcare_precov_hlp_offcampus) | !missing(chldcare_precov_hlp_respondent) | !missing(chldcare_precov_hlp_other ))
sum partnercaregiver					   
					   
**Mentorship

gen mentorlevel = 0 if !missing(mentor)
replace mentorlevel = 1 if !missing(mentor) & mentor==2
replace mentorlevel = 2 if !missing(mentor) & mentor==3

label define mentordesc 0 "No Mentor" 1 "1 Mentor"
label define mentordesc 2 ">1 Mentor", modify

label values mentorlevel mentordesc

gen mentorconnect = 1 if mentor_assigned_or_connect==2
replace mentorconnect = 0 if mentor_assigned_or_connect==1


gen mentorsamegender = 0 if !missing(mentor_gender)
replace mentorsamegender = 1 if !missing(mentor_gender) & mentor_gender==2


**Avoidance of opps

gen notapply = 0 if !missing(avoid_notapply)
replace notapply = 1 if !missing(avoid_notapply) & avoid_notapply==2

gen leftpos = 0 if !missing(avoid_leftpost)
replace leftpos = 1 if !missing(avoid_leftpost) & avoid_leftpost==2

gen notresearch = 0 if !missing(avoid_notresearch)
replace notresearch = 1 if !missing(avoid_notresearch) & avoid_notresearch==2


**Citations

*drop great_cite_coauthor great_cite_colleague great_cite_conf great_cite_conv great_cite_litsearch great_cite_pressure

gen great_cite_coauthor = 100 if cite_coauthor==4 | cite_coauthor==5
replace great_cite_coauthor = 0 if !missing(cite_coauthor) & cite_coauthor !=4 & cite_coauthor !=5

gen great_cite_colleague = 100 if cite_colleague==4 | cite_colleague==5
replace great_cite_colleague = 0 if !missing(cite_colleague) & cite_colleague !=4 & cite_colleague !=5

gen great_cite_conf = 100 if cite_conf==4 | cite_conf==5
replace great_cite_conf = 0 if !missing(cite_conf) & cite_conf !=4 & cite_conf !=5

gen great_cite_sem = 100 if cite_seminar==4 | cite_seminar==5
replace great_cite_sem = 0 if !missing(cite_seminar) & cite_seminar !=4 & cite_seminar !=5

gen great_cite_conv = 100 if cite_conv==4 | cite_conv==5
replace great_cite_conv = 0 if !missing(cite_conv) & cite_conv !=4 & cite_conv !=5

gen great_cite_litsearch = 100 if cite_litsearch==4 | cite_litsearch==5
replace great_cite_litsearch = 0 if !missing(cite_litsearch) & cite_litsearch !=4 & cite_litsearch !=5

gen great_cite_pressure = 100 if cite_pressure==4 | cite_pressure==5
replace great_cite_pressure = 0 if !missing(cite_pressure) & cite_pressure !=4 & cite_pressure !=5

*drop some_cite_coauthor some_cite_colleague some_cite_conf some_cite_conv some_cite_litsearch some_cite_pressure
gen some_cite_coauthor = 100 if cite_coauthor==3
replace some_cite_coauthor = 0 if !missing(cite_coauthor) & cite_coauthor !=3

gen some_cite_colleague = 100 if cite_colleague==3
replace some_cite_colleague = 0 if !missing(cite_colleague) & cite_colleague !=3

gen some_cite_conf = 100 if cite_conf==3
replace some_cite_conf = 0 if !missing(cite_conf) & cite_conf !=3

gen some_cite_sem = 100 if cite_seminar==3
replace some_cite_sem = 0 if !missing(cite_seminar) & cite_seminar !=3

gen some_cite_conv = 100 if cite_conv==3
replace some_cite_conv = 0 if !missing(cite_conv) & cite_conv !=3

gen some_cite_litsearch = 100 if cite_litsearch==3
replace some_cite_litsearch = 0 if !missing(cite_litsearch) & cite_litsearch !=3

gen some_cite_pressure = 100 if cite_pressure==3
replace some_cite_pressure = 0 if !missing(cite_pressure) & cite_pressure !=3


**Mentorship


gen havementor = 100 if mentor==2 | mentor==3
replace havementor = 0 if mentor==1

gen havemultmentor = 100 if mentor==3
replace havemultmentor = 0 if mentor==1 | mentor==2

gen havementorsamegen = 100 if mentor_gender==2
replace havementorsamegen = 0 if mentor_gender==1

gen havementoripick = 100 if mentor_assigned_or_connect==2
replace havementoripick = 0 if mentor_assigned_or_connect==1

gen havementorassd = 100 if mentor_assigned_or_connect==1
replace havementorassd = 0 if mentor_assigned_or_connect==2


**Pipeline variables

gen pipe = 1 if student==1
replace pipe = 2 if tenured==0
replace pipe = 3 if tenured==1

label define pipedesc 1 "Student" 2 "Untenured"
label define pipedesc 3 "Tenured", modify

label values pipe pipedesc



**Job satisfaction variables - convert to dummies

foreach d in job_concerns job_workharder job_opportunities job_inccolleagues job_advancement job_suprespect job_tknseriously job_workrespect {
	gen dum`d' = 100 if `d'==5 | `d'==6
	replace dum`d' = 0 if `d'==1 |  `d'==2 |`d'==3 |`d'==4
}

**Flip negative job concern variables to make them positive, and make alt variables

gen dumjob_concerns2 = 100 if job_concerns==1 | job_concerns==2
gen dumjob_workharder2 = 100 if job_workharder==1 | job_workharder==2
gen dumjob_opportunities2 = 100 if job_opportunities==1 | job_opportunities==2

replace dumjob_concerns2 = 0 if job_concerns==3 | job_concerns==4 | job_concerns==5 | job_concerns==6
replace dumjob_workharder2 = 0 if job_workharder==3 | job_workharder==4 | job_workharder==5 | job_workharder==6
replace dumjob_opportunities2 = 0 if job_opportunities==3 | job_opportunities==4 | job_opportunities==5 | job_opportunities==6



**Quality researcher*/

gen qualresearcher=1 if pub_top3fin==4
replace qualresearcher=0 if pub_top3fin==1 | pub_top3fin==2 | pub_top3fin==3 

**Theory

gen theory =1 if type_research==1
replace theory=0 if type_research==2

gen empirical = 1 if type_research==2
replace empirical = 0 if type_research==1



**Renee variable creation***************************************************************************************************

rename likeme_creative  selfdirection 
rename likeme_rich power  
rename likeme_secure security
rename likeme_goodtime hedonism
rename likeme_dogood benevolence_b			//have not found anyone using this one
rename likeme_help benevolence_a
rename likeme_successful achievement
rename likeme_adventure stimulation
rename  likeme_proper conformity
rename likeme_environment universalism
rename likeme_tradition tradition

**recode as in Schwartz 


****data cleaning 
***original schwartz with 57 questions:	Subjects who leave 15 or more items blank are to be dropped from the analysis.
***** our case: drop if more than choose (15/57)*10=2.6 --> 3 missing

egen nummiss2=rmiss(selfdirection power security hedonism benevolence_a achievement stimulation conformity universalism tradition benevolence_b)
gen valmiss3=0
replace valmiss3=1 if nummiss2>=3

***original schwartz with 57 questions:	Subjects who use a particular scale anchor 35 times or more should be dropped; e.g., if the anchor point ӳԠis selected 35 times or more.
*****drop if always choose (35/57)*10=6.14 times same answer

****neqany(varlist), v(numlist) equals number of variables in varlist equal to any of the values in numlist. 


egen num1=neqany(selfdirection power security hedonism benevolence_a achievement stimulation conformity universalism tradition benevolence_b), values(1)
egen num2=neqany(selfdirection power security hedonism benevolence_a achievement stimulation conformity universalism tradition benevolence_b), values(2)
egen num3=neqany(selfdirection power security hedonism benevolence_a achievement stimulation conformity universalism tradition benevolence_b), values(3)
egen num4=neqany(selfdirection power security hedonism benevolence_a achievement stimulation conformity universalism tradition benevolence_b), values(4)
egen num5=neqany(selfdirection power security hedonism benevolence_a achievement stimulation conformity universalism tradition benevolence_b), values(5)
egen num6=neqany(selfdirection power security hedonism benevolence_a achievement stimulation conformity universalism tradition benevolence_b), values(6)
egen num7=neqany(selfdirection power security hedonism benevolence_a achievement stimulation conformity universalism tradition benevolence_b), values(7)

gen valanchor7=1 if num1>6 | num2>6 | num3>6 | num4>6 | num5>6 | num6>6 | num7>6

gen drop=0
replace drop=1 if valmiss3==1 | valanchor7==1 


***************centering
egen mrat=rmean(selfdirection power security hedonism benevolence_a achievement stimulation conformity universalism tradition benevolence_b)

local explist = " selfdirection power security hedonism benevolence_a achievement stimulation conformity universalism tradition benevolence_b "
 foreach X of local explist {
 gen c`X'=`X'-mrat
 label var c`X' "Schwartz value c`X'"
}

gen cConservation = 1/2*csecurity + 1/4*cconformity + 1/4*ctradition
gen cSelfTran     = 1/3*cuniversalism + 1/3*cbenevolence_a + 1/3*cbenevolence_b
gen cSelfEnh      = 0.4*cpower + 0.4*cachievement + 0.2*chedonism
gen cOpenChg      = 0.4*cstimulation + 0.4*cselfdirection + 0.2*chedonism

// Collapse to two

gen cCons_OpenChg = cConservation - cOpenChg
gen cSelfTran_SelfEnh = cSelfTran - cSelfEnh


**Generate job satisfaction index coarse

foreach d in job_concerns job_workharder job_opportunities  {

gen `d'cat = 3 if `d'==1 | `d'==2
replace `d'cat = 2 if `d'==3 | `d'==4
replace `d'cat = 1 if `d'==5 | `d'==6

}

foreach d in job_inccolleagues job_advancement job_suprespect job_tknseriously job_workrespect   {

gen `d'cat = 1 if `d'==1 | `d'==2
replace `d'cat = 2 if `d'==3 | `d'==4
replace `d'cat = 3 if `d'==5 | `d'==6

}

gen jobsatposindex = job_concernscat + job_workhardercat + job_opportunitiescat + job_inccolleaguescat  + job_advancementcat  + job_suprespectcat  + job_tknseriouslycat  + job_workrespectcat

**Generate job satisfaction index detailed

foreach d in job_concerns job_workharder job_opportunities  {

gen `d'temp = 6 if `d'==1 
replace `d'temp = 5 if `d'==2 
replace `d'temp = 4 if `d'==3 
replace `d'temp = 3 if `d'==4 
replace `d'temp = 2 if `d'==5 
replace `d'temp = 1 if `d'==6 

}

gen jobsatdetailindex = job_concernstemp + job_workhardertemp + job_opportunitiestemp + job_inccolleagues  + job_advancement  + job_suprespect  + job_tknseriously + job_workrespect



**Geographical dummies


gen europe = 1 if region_now==4
replace europe = 0 if region_now != 4 & !missing(region_now)

gen usa = 1 if region_now==6
replace usa = 0 if region_now != 6 & !missing(region_now)

gen asia_aus = 1 if region_now==2 | region_now==3
replace asia_aus = 0 if region_now != 2 & region_now != 3 & !missing(region_now)

gen region_now3grps = 1 if europe==1
replace region_now3grps = 2 if usa==1
replace region_now3grps = 3 if asia_aus==1
replace region_now3grps = 4 if europe==0 & usa==0 & asia_aus==0 & !missing(region_now)

label define regiondesc 1 "Europe" 2 "N America", modify
label define regiondesc 3 "Asia / Australia)" 4 "Other" , modify

label values region_now3grps regiondesc


**Import excel data on response time********************************************

save main, replace

clear

import excel using "C:\Users\ml3237\Dropbox\Climate Survey\Survey data from NORC_Final\AFA time stamp delivery.xlsx", sheet("AFA time stamp delivery") first
save time, replace

use main, clear
merge 1:1 norc_generated_randomid using time

save main2, replace



**Record dates on which emails went out

use main2

gen respdayemail = 1 if END_DATE == mdy(11,23,2020) | END_DATE == mdy(12,2,2020) | END_DATE == mdy(12,10,2020) | END_DATE == mdy(12,15,2020) | END_DATE == mdy(12,22,2020) |  ///
                     END_DATE == mdy(12,29,2020) | END_DATE == mdy(1,7,2020) 
					 
replace respdayemail = 0 if missing(respdayemail)
sum respdayemail

save main2, replace


**Obtain # responses per day and categorize days into buckets of time (based on email dates)
					 
sort END_DATE
by END_DATE: gen numrespperday = _n
by END_DATE: keep if _n==_N

gen respdayct = _n


gen respdaybucket = 1 if END_DATE < mdy(12,2,2020)
replace respdaybucket = 2 if END_DATE >= mdy(12,2,2020) & END_DATE < mdy(12,10,2020)
replace respdaybucket = 3 if END_DATE >= mdy(12,10,2020) & END_DATE < mdy(12,15,2020)
replace respdaybucket = 4 if END_DATE >= mdy(12,15,2020) & END_DATE < mdy(12,22,2020)
replace respdaybucket = 5 if END_DATE >= mdy(12,22,2020) & END_DATE < mdy(12,29,2020)
replace respdaybucket = 6 if END_DATE >= mdy(12,29,2020) & END_DATE < mdy(1,7,2021)
replace respdaybucket = 7 if END_DATE >= mdy(1,7,2021)

label define respdesc 1 "11/23/2020" 2 "12/2/2020", modify
label define respdesc 3 "12/10/2020" 4 "12/15/2020" 5 "12/22/2020" 6 "12/29/2020" 7 "1/7/2021", modify
label values respdaybucket respdesc

keep END_DATE numrespperday respdayct respdaybucket respdayemail 

save part_resptime, replace
sum numrespperday, d
sort END_DATE
list END_DATE respdayct respdayemail numrespperday respdaybucket

**Merge these daily data back into main file

use main2, clear
drop _merge

merge m:1 END_DATE using part_resptime

save main3, replace


**A few other variables

gen respbucket1 = 1 if respdaybucket==1
replace respbucket1 = 0 if respdaybucket>1


gen speakerfemaledum = 1 if speaker_female==2
replace speakerfemaledum = 0 if speaker_female==1

gen lastofferfemale = 1 if last_offer==2 | last_offer==3 | last_offer==1
replace lastofferfemale = 0 if last_offer==4 | last_offer==5

gen femaleaccepted = 1 if last_offer==2 | last_offer_accept==2
replace femaleaccepted = 0 if last_offer==3 | last_offer==4 | last_offer==5 | last_offer_accept==1



**sources of childcare


gen chldcare_precov_source_ans = 1 if !missing(chldcare_precov_hlp_caregiver) | !missing(chldcare_precov_hlp_oncampus) | !missing(chldcare_precov_hlp_offcampus) | !missing(chldcare_precov_hlp_partner) | !missing(chldcare_precov_hlp_respondent)
replace chldcare_precov_source_ans = 0 if missing(chldcare_precov_hlp_caregiver) & missing(chldcare_precov_hlp_oncampus) & missing(chldcare_precov_hlp_offcampus) & missing(chldcare_precov_hlp_partner) & missing(chldcare_precov_hlp_respondent)  

gen chldcare_caregiverML = 1 if chldcare_precov_hlp_caregiver==1 & chldcare_precov_source_ans == 1
replace chldcare_caregiverML = 0 if chldcare_precov_hlp_caregiver !=1 & chldcare_precov_source_ans == 1

gen chldcare_oncampusML = 1 if chldcare_precov_hlp_oncampus==1 & chldcare_precov_source_ans == 1
replace chldcare_oncampusML = 0 if chldcare_precov_hlp_oncampus !=1 & chldcare_precov_source_ans == 1

gen chldcare_offcampusML = 1 if chldcare_precov_hlp_offcampus==1 & chldcare_precov_source_ans == 1
replace chldcare_offcampusML = 0 if chldcare_precov_hlp_offcampus !=1 & chldcare_precov_source_ans == 1

gen chldcare_partnerML = 1 if chldcare_precov_hlp_partner==1 & chldcare_precov_source_ans == 1
replace chldcare_partnerML = 0 if chldcare_precov_hlp_partner !=1 & chldcare_precov_source_ans == 1

gen chldcare_respondentML = 1 if chldcare_precov_hlp_respondent==1 & chldcare_precov_source_ans == 1
replace chldcare_respondentML = 0 if chldcare_precov_hlp_respondent !=1 & chldcare_precov_source_ans == 1

gen chldcare_onoffML = 1 if chldcare_oncampusML==1 | chldcare_offcampusML==1
replace chldcare_onoffML = 0 if chldcare_oncampusML==0 & chldcare_offcampusML==0




gen childcare1 = 1 if chldcare_caregiverML==1 | chldcare_onoffML==1
replace childcare1 = 0 if chldcare_caregiverML==0 & chldcare_onoffML==0
label var childcare1 "Caregiver or Daycare"

gen childcare2 = 1 if chldcare_caregiverML==1 | chldcare_onoffML==1 | chldcare_partnerML==1
replace childcare2 = 0 if chldcare_caregiverML==0 & chldcare_onoffML==0 & chldcare_partnerML==0


**eldercare


gen eldercareML = 1 if eldercare==5
replace eldercareML = 2 if eldercare==1
replace eldercareML = 3 if eldercare==2
replace eldercareML = 4 if eldercare==3
replace eldercareML = 5 if eldercare==4

label define elderdesc 1 "I do not have elder care responsibilities" 2 "Less than 1 hour"
label define elderdesc 3 "1 - 5 hours" 4 "6 - 10 hours" 5 "More than 10 hours" , modify

label values eldercareML elderdesc


**competitive counteroffer

gen countergood = 1 if unsolicited_counter==4
replace countergood = 0 if unsolicited_counter==1 | unsolicited_counter==2 | unsolicited_counter==3
label var countergood "Competitive Counter-Offer Dummy"


**accomodation by employer 

gen interruption_accom_rev = 0 if interruption_accom == 1 | (interruption_accom ==2 & interruption_accom_enc == 1)
replace interruption_accom_rev = 1 if interruption_accom ==2 & interruption_accom_enc == 2
label var interruption_accom_rev "Employer made and encouraged accomodation"

**put discrimination variables in differnet units and generate unconditional discrimination variables

gen discrim_pers_dumML01 = discrim_pers_dumML / 100
gen discrim_wit_dumML01 = discrim_wit_dumML / 100

foreach d in discrim_pers_sexML discrim_pers_ageML discrim_pers_raceML discrim_pers_researchML discrim_pers_familyML discrim_pers_politicsML  discrim_pers_orientationML discrim_pers_religionML discrim_pers_disabilityML {
	
	gen `d'un = `d'/100 if !missing(`d')
	replace `d'un = 0 if missing(`d') & discrim_pers_dumML == 0
	
}

foreach d in   discrim_wit_sexML discrim_wit_ageML discrim_wit_raceML discrim_wit_researchML discrim_wit_familyML discrim_wit_politicsML  discrim_wit_orientationML discrim_wit_religionML discrim_wit_disabilityML {
	
	gen `d'un = `d'/100 if !missing(`d')
	replace `d'un = 0 if missing(`d') & discrim_wit_dumML == 0
	
}


** Make unconditional versions of time variables***************************************************************************************************************


foreach d in   time_research2 time_childcare2  time_teaching2 time_teachingact2  time_email2  time_mtg2 time_social2 time_relax2 time_service2 time_exercise2 time_hobbies2 time_consult2 time_external2 time_volunteer2 {
	
	gen `d'a = `d' if !missing(`d') & !missing(time_sleep2)
	replace `d'a = 0 if missing(`d') & !missing(time_sleep2)
	
}

gen time_teachall2a = time_teaching2a + time_teachingact2a
gen time_nonwork2a = time_social2a + time_relax2a +  time_exercise2a + time_hobbies2a +  time_volunteer2a
gen time_emailmtg2a =  time_email2a + time_mtg2a
gen time_consultext2a =  time_consult2a + time_external2a



**Revise job satisfaction varialbes


foreach d in job_concerns job_workharder job_opportunities {
	
	gen `d'rev = 6 if `d' == 1
	replace `d'rev = 5 if `d' == 2
	replace `d'rev = 4 if `d' == 3
	replace `d'rev = 3 if `d' == 4
	replace `d'rev = 2 if `d' == 5
	replace `d'rev = 1 if `d' == 6
	
}


**Areas of research

gen behav = 1 if area_research==3
replace behav = 0 if area_research !=3

gen finint = 1 if area_research==5
replace finint = 0 if area_research !=5

gen hh = 1 if area_research==6
replace hh = 0 if area_research !=6

label var behav "Behavioral"
label var finint "Finl Intermediation"
label var hh "Household Fin"


**other demographics for desc stats

gen seminvite = inperson_invite + virtual_invite if !missing(inperson_invite) & !missing(virtual_invite)
replace seminvite = inperson_invite  if !missing(inperson_invite) & missing(virtual_invite)
replace seminvite = virtual_invite   if  missing(inperson_invite) & !missing(virtual_invite)

gen discussant = paper_comment

gen keynote = 1 if keynote_invite==1 | keynote_invite==2
replace keynote = 0 if keynote_invite == 0

gen seminvitebucket = 1 if seminvite == 0
replace seminvitebucket = 2 if seminvite == 1 | seminvite == 2
replace seminvitebucket = 3 if seminvite == 3 | seminvite == 4 | seminvite == 5
replace seminvitebucket = 4 if seminvite == 6 | seminvite == 7 | seminvite == 8
replace seminvitebucket = 5 if seminvite == 9 | seminvite == 10

label define semdesc 1 "0" 2 "1 - 2"
label define semdesc 3 "3 - 5" 4 "6 - 8" 5 "9 or more" , modify

label values seminvitebucket semdesc



**Create variables with units in 100s


*drop femaleT usaT europeT asia_ausT studentT facultyT nonfacresearcherT nonresearcherT untenuredT corpfinT asstprcT behavT finintT hhT theoryT empiricalT keynoteT

foreach d in female usa europe asia_aus student faculty nonfacresearcher nonresearcher untenured corpfin asstprc behav finint hh theory empirical keynote topschool {
	gen `d'T = `d'*100
	_crcslbl `d'T  `d' 
}



gen children_under_18dum = children_under_18 - 1

**Fix PhD year
gen phd_yearML = 1 if phd_year_suppressed==1
replace phd_yearML = 2 if phd_year_suppressed==8
replace phd_yearML = 3 if phd_year_suppressed==9
replace phd_yearML = 4 if phd_year_suppressed==10
replace phd_yearML = 5 if phd_year_suppressed==11
replace phd_yearML = 6 if phd_year_suppressed==12
replace phd_yearML = 7 if phd_year_suppressed==13
replace phd_yearML = 8 if phd_year_suppressed==14
replace phd_yearML = 9 if phd_year_suppressed==15

label var phd_yearML "Phd Year"

label define phddesc 1 "< 1980" 2 "81 - 85", modify
label define phddesc 3 "86 - 90" 4 "91 - 95" 5 "96 - 00" 6 "01 - 05" 7 "06 - 10" 8 "11 - 15" 9 "16 - 20", modify
label values phd_yearML phddesc



**mentor_assigned_or_connect


gen mentorassigned = 1 if mentorconnect == 0
replace mentorassigned = 0 if mentorconnect == 1
label var mentorassigned "Mentor was assigned to me"

**Variables for fig 11 on personal experiences and professional outcomes*****************************************************************************************************-
gen highchildcare = 1 if time_childcare>=3 & !missing(time_childcare)
replace highchildcare = 0 if time_childcare<3 & !missing(time_childcare)

gen highdeptsharing = 100 if scifree_dept >= 5 & !missing(scifree_dept)
replace highdeptsharing = 0 if scifree_dept <=4 & !missing(scifree_dept)

gen lowdeptsharing = 100 if scifree_dept <= 2 & !missing(scifree_dept)
replace lowdeptsharing = 0 if scifree_dept >=3 & !missing(scifree_dept)

gen leftpost = 100 if avoid_leftpost == 2
replace leftpost = 0 if avoid_leftpost == 1

gen leftresearch = 100 if avoid_notresearch == 2
replace leftresearch = 0 if avoid_notresearch == 1

gen lowsat = 100 if jobsatposindex <= 16
replace lowsat = 0 if jobsatposindex > 16

**seminars

egen seminar = rowtotal(inperson_invite virtual_invite)
sum seminar inperson_invite virtual_invite

gen seminarcat = 0 if seminar == 0
replace seminarcat = 1 if seminar==1 | seminar==2 | seminar==3 | seminar==4 | seminar==5
replace seminarcat = 2 if seminar==6 | seminar==7 | seminar==8 | seminar==9 | seminar==10

gen discussantcat = 0 if discussant == 0
replace discussantcat = 1 if discussant==1 | discussant==2 
replace discussantcat = 2 if discussant==3 | discussant==4 | discussant==5


**interruptions 
gen interruptionML = 1 if interruption==1
replace interruptionML = 2 if (interruption == 2 | interruption==3) & interruption_accom==1
replace interruptionML = 3 if (interruption == 2 | interruption==3) & interruption_accom==2 & interruption_accom_enc==1
replace interruptionML = 4 if (interruption == 2 | interruption==3) & interruption_accom==2 & interruption_accom_enc==2




*drop interup1 interupmult

gen interup1 = 100 if interruption == 2
replace interup1 = 0 if interruption != 2

gen interupmult = 100 if interruption == 3
replace interupmult = 0 if interruption != 3

label var interup1 "1"
label var interupmult ">1"

**pipestage

gen pipestage = 1 if roleML==1
replace pipestage = 2 if roleML==2 & untenured==1
replace pipestage = 3 if roleML==2 & untenured==0

label define pipedesc 1 "Student" 2 "Untenured Prof", modify
label define phddesc 3 "Tenured Prof" , modify
label values pipestage pipedesc


**Variables for job offers 

gen last_offer_f = 100 if last_offer==2 | lastoffer==3
replace last_offer_f = 0 if last_offer==4 | lastoffer==5

gen last_offer_m = 100 if last_offer==4 | lastoffer==5
replace last_offer_m = 0 if last_offer==2 | lastoffer==3

gen student_f=100 if student==1 & female==1
replace student_f=0 if student==1 & female==0

gen student_m=100 if student==1 & female==0
replace student_m=0 if student==1 & female==1

gen untenured_f = 100 if untenured==1 & female==1
replace untenured_f = 0 if untenured==1 & female==0

gen tenured_f = 100 if untenured==0 & female==1
replace tenured_f = 0 if untenured==0 & female==0


**workplace type 

gen worktype = 1 if topschool==1
replace worktype = 2 if topschool==0
replace worktype = 3 if workplacetype==2
replace worktype = 4 if workplacetype==3

label define workplacedesc 1 "Top Research Univs" 2 "All Other Univs", modify
label define workplacedesc 3 "Govt Agency" 4 "ForProfit Co", modify
label values worktype workplacedesc
tab worktype

gen job_tknseriouslysum = 1 if job_tknseriously==1 | job_tknseriously==2
replace job_tknseriouslysum = 2 if job_tknseriously==3 | job_tknseriously==4
replace job_tknseriouslysum = 3 if job_tknseriously==5 | job_tknseriously==6

label define jobtakendesc 1 "Disagree/Strongly disagree" 2 "Somewhat agree/disagree"
label define jobtakendesc 3 "Agree/Strongly agree" , modify
label values job_tknseriouslysum jobtakendesc

gen job_concernssum = 1 if job_concerns==1 | job_concerns==2
replace job_concernssum = 2 if job_concerns==3 | job_concerns==4
replace job_concernssum = 3 if job_concerns==5 | job_concerns==6


label define jobconcerndesc 1 "Agree/Strongly agree" 2 "Somewhat agree/disagree", modify
label define jobconcerndesc 3 "Disagree/Strongly disagree" , modify
label values job_concernssum jobconcerndesc

gen worktypemod = 1 if topschool==1
replace worktypemod = 2 if workplacetype==2
replace worktypemod = 3 if workplacetype==3 
replace worktypemod = 4 if topschool==0 & workplacetype==1

label define workmoddesc 1 "Top Research Univs" 2 "Govt Agency", modify
label define workmoddesc 3 "ForProfit Co" 4 "All Other Univs", modify
label values worktypemod workmoddesc




**Label variables***************************************************************************************************************


label var seminvite "Seminar invitations"
label var discussant "Discussions"
label var keynote "Keynote"

label var time_research2a "Research"
label var time_childcare2a "Childcare"
label var time_teaching2a "Teaching"
label var time_teachingact2a "Teaching Prep"
label var time_email2a "Email"
label var time_mtg2a "Mtgs w Colleagues"
label var time_social2a "Social"
label var time_relax2a "Relaxing"
label var time_service2a "Service"
label var time_exercise2a "Exercise"
label var time_hobbies2a "Hobbies"
label var time_consult2a "Consulting"
label var time_external2a "External Engagement"
label var time_volunteer2a "Volunteering"
label var time_teachall2a "Teaching"
label var time_emailmtg2a "Email / Mtgs"
label var time_consultext2a "External Work"
label var time_nonwork2a "Personal Time"


label var discrim_pers_dumML01 "Experienced Discrimination"
label var discrim_wit_dumML01 "Witnessed Discrimination"
label var cachievement "Achievement"
label var cselfdirection "Self-direction"

label var mentorconnect "Connected to Mentor On Own"

label var female "Female"
label var untenured "Not Tenured"
label var tenuredML "Tenured"
label var researcher "Researcher"
label var student "Student"
label var citations "Citations"

label var black "Black"
label var asian "Asian"
label var hispanic "Hispanic"
label var mideast "Middle Eastern"
label var white "Causcasian"
label var other "Other Race"
label var minority "Non-Asian Minority"

label var bornoutsideus "Born Outside US"
label var liveoutsideus "Live Outside US"

label var newproj_precov  "Started New Project Pre-Covid"
label var newproj_precov_newperson "Started New Project Pre-Covid, with new person"
label var newproj_postcov  "Started New Project Post-Covid"
label var newproj_postcov_newperson "Started New Project Post-Covid, with new person"


label var discrim_pers_dumML "Experienced Discrimination"
label var discrim_wit_dumML "Witnessed Discrimination"
label var discrim_authaddress_dumML "Authority Addressed Disc."
label var discrim_authaddress_dumreg "Authority Addressed Disc."

label var topschool "Research Intensive Institution"

label var QUES_SEM "Comfort Asking Questions in Seminars"
label var QUES_CONF "Comfort Asking Questions in Conferences"

label var childdutiescov "Child Duties During Covid"
label var childdutiespre "Child Duties Pre-Covid"

label var time_sleep2 "Sleep"
label var time_research2 "Research"
label var time_childcare2 "Childcare"
label var time_teaching2 "Teaching"
label var time_teachingact2 "Teaching Prep"
label var time_email2 "Email"
label var time_mtg2 "Meetings"
label var time_social2 "Social"
label var time_relax2 "TV / Reading"
label var time_service2 "Service"
label var time_exercise2 "Exercise"
label var time_hobbies2 "Hobbies"
label var time_consult2 "Consulting"
label var time_external2 "Ext Engagement"
label var time_volunteer2 "Volunteering"

label var time_teachall2 "Teaching"
label var time_emailmtg2 "Email / Mtgs"
label var time_consultext2 "External Work"
label var time_nonwork2 "Personal Time"

label var europe "Europe"
label var usa "N America"
label var asia_aus "Asia / Australia"


	
label var lesschgtime_teach "Teaching"
label var lesschgtime_teachact "Teaching Prep"
label var lesschgtime_research "Research"
label var lesschgtime_childcare "Childcare"	

label var morechgtime_teach "Teaching"
label var morechgtime_teachact "Teaching Prep"
label var morechgtime_research "Research"
label var morechgtime_childcare "Childcare"	

label var lesschgtime_class_student "Class"
label var lesschgtime_acawork_student "Classwork"
label var lesschgtime_employ_student "TA, RA, etc"
label var lesschgtime_research_student "Research"
label var lesschgtime_childcare_student "Childcare"
label var lesschgtime_social_student "Social"
label var lesschgtime_relax_student "TV / Reading"
label var lesschgtime_exercise_student "Exercise"
label var lesschgtime_hobbies_student "Hobbies"
label var lesschgtime_sleep_student "Sleep"

label var morechgtime_class_student "Class"
label var morechgtime_acawork_student "Classwork"
label var morechgtime_employ_student "TA, RA, etc"
label var morechgtime_research_student "Research"
label var morechgtime_childcare_student "Childcare"
label var morechgtime_social_student "Social"
label var morechgtime_relax_student "TV / Reading"
label var morechgtime_exercise_student "Exercise"
label var morechgtime_hobbies_student "Hobbies"
label var morechgtime_sleep_student "Sleep"

label var lchgtime_mtg_non_academic "Meetings"
label var lchgtime_email_non_academic "Email" 
label var lchgtime_research_non_academic  "Research"
label var lchgtime_service_non_academic "Service"
label var lchgtime_consult_non_academic "Consulting"
label var lchgtime_external_non_academic "Ext Engagement"
label var lchgtime_childcare_non_academic "Childcare"
label var lchgtime_social_non_academic "Social"        
label var lchgtime_relax_non_academic "TV / Reading"
label var lchgtime_volunteer_non_academic "Volunteer" 
label var lchgtime_exercise_non_academic "Exercise"
label var lchgtime_hobbies_non_academic "Hobbies"
label var lchgtime_sleep_non_academic "Sleep"

label var mchgtime_mtg_non_academic "Meetings"
label var mchgtime_email_non_academic "Email" 
label var mchgtime_research_non_academic  "Research"
label var mchgtime_service_non_academic "Service"
label var mchgtime_consult_non_academic "Consulting"
label var mchgtime_external_non_academic "Ext Engagement"
label var mchgtime_childcare_non_academic "Childcare"
label var mchgtime_social_non_academic "Social"        
label var mchgtime_relax_non_academic "TV / Reading"
label var mchgtime_volunteer_non_academic "Volunteer" 
label var mchgtime_exercise_non_academic "Exercise"
label var mchgtime_hobbies_non_academic "Hobbies"
label var mchgtime_sleep_non_academic "Sleep"



label var discrim_pers_raceML "Race"
label var discrim_pers_sexML "Gender"
label var discrim_pers_orientationML "Orientation"
label var discrim_pers_disabilityML "Disability"
label var discrim_pers_familyML "Family"
label var discrim_pers_religionML "Religion"
label var discrim_pers_politicsML "Politics"
label var discrim_pers_ageML "Age"
label var discrim_pers_researchML "Research"

label var discrim_wit_raceML "Race"
label var discrim_wit_sexML "Gender"
label var discrim_wit_orientationML "Orientation"
label var discrim_wit_disabilityML "Disability"
label var discrim_wit_familyML "Family"
label var discrim_wit_religionML "Religion"
label var discrim_wit_politicsML "Politics"
label var discrim_wit_ageML "Age"
label var discrim_wit_researchML "Research"

label var avoid_notapplyML "Not apply for particular position"
label var avoid_leftpostML "Leave particular position"
label var avoid_notresearchML "Not research w/i particular field"

label var great_cite_coauthor "Co-author"
label var great_cite_colleague "Colleague"
label var great_cite_conf "Conference"
label var great_cite_sem "Seminar"
label var great_cite_conv "Conversation"
label var great_cite_litsearch "Lit search"
label var great_cite_pressure "Pressured to add"

label var some_cite_coauthor "Co-author"
label var some_cite_colleague "Colleague"
label var some_cite_conf "Conference"
label var some_cite_sem "Seminar"
label var some_cite_conv "Conversation"
label var some_cite_litsearch "Lit search"
label var some_cite_pressure "Pressured to add"


label var havementor "Have a mentor"
label var havemultmentor "Have >1 mentor"
label var havementorsamegen "Mentor same gender"
label var havementoripick "Informal mentor"
label var havementorassd "Mentor was formally assigned"


label var dumjob_concerns "Reluctant raise issues"
label var dumjob_workharder "Have to work harder"
label var dumjob_opportunities "Don't have same opps"
label var dumjob_inccolleagues "Colleagues include me"
label var dumjob_advancement "Equal standards app'd"
label var dumjob_suprespect "Superviser respects me"
label var dumjob_tknseriously "Views taken seriously"
label var dumjob_workrespect "Work is respected"

label var newproj_precovPct "Pre-Covid"
label var newproj_postcovPct "Post-Covid"

label var time_class_student2 "Class"
label var time_acawork_student2 "Classwork"
label var time_employ_student2 "TA, RA, etc"
label var time_research_student2 "Research"
label var time_childcare_student2 "Childcare"
label var time_social_student2 "Social"
label var time_relax_student2 "TV / Reading"
label var time_exercise_student2 "Exercise"
label var time_hobbies_student2 "Hobbies"
label var time_sleep_student2 "Sleep"

label var time_mtg_non_academic "Meetings"
label var time_email_non_academic "Email"
label var time_research_non_academic "Research"
label var time_service_non_academic "Service"
label var time_consult_non_academic "Consulting"
label var time_external_non_academic "Ext Engagement"
label var time_childcare_non_academic "Childcare"
label var time_social_non_academic "Social"
label var time_relax_non_academic "TV / Reading"
label var time_volunteer_non_academic "Volunteer"
label var time_exercise_non_academic "Exercise"
label var time_hobbies_non_academic "Hobbies"
label var time_sleep_non_academic "Sleep"

label var num_pub "# Publications"
label var asstprc "Asset Pricing"
label var corpfin "Corp Finance"

label var qualresearcher "Publish primarily in Top3"
label var theory "Theory"
label var empirical "Empirical"

label var jobsatposindex "Job Satisfaction"
label var jobsatdetailindex "Job Satisfaction"

label var speakerfemaledum "Most Recent Seminar Speaker was Female"
label var lastofferfemale "Most Recent Offer Made to Female"
label var femaleaccepted "Most Recent Accepted Offer was to Female"


label var chldcare_caregiverML "Caregiver"
label var chldcare_oncampusML "OnCampus"
label var chldcare_offcampusML "OffCampus"
label var chldcare_onoffML "Daycare"
label var chldcare_partnerML "Partner"
label var chldcare_respondentML "Respondent"
label var partnercaregiver "Partner who helps care for children "

label var dumjob_concerns2   "Comfort raising issues"
label var dumjob_workharder2 "Equal effort required"
label var dumjob_opportunities2 "Equal opportunities"

save main3, replace





*********************************************************************************************************************
*********************************************************************************************************************
**Graphs depicting char's of data 
*********************************************************************************************************************
*********************************************************************************************************************

**Set default scheme
set scheme s2color
*set scheme economist

global attout        blabel(bar, position(outside) color(black) format(%3.1f) size(3))  ysize(3) xsize(5) l1title("") ytitle(Percent of Respondents) 
global attoutsmall   blabel(bar, position(outside) color(black) format(%3.1f) size(2))  ysize(3) xsize(5) l1title("") ytitle(Percent of Respondents) 
global attin         blabel(bar, position(inside)  color(white) format(%3.1f) size(3))  ysize(3) xsize(5) l1title("") ytitle(Percent of Respondents) 

global attoutcrowded blabel(bar, position(outside) color(black) format(%3.1f) size(2))  ysize(4) xsize(3) l1title("") ytitle(Percent of Respondents)

global titlsiz 0.8

global contfac  female untenured  citations num_pub topschool    corpfin asstprc europe usa asia_aus
global contfacWOfem    untenured  citations num_pub topschool    corpfin asstprc europe usa asia_aus
global sourcedif discrim_pers_dumML01 discrim_wit_dumML01 cachievement cselfdirection  childdutiespre

global contoth  female phd_yearML europe usa asia_aus

global jobsat jobsatdetailindex
*global jobsat jobsatposindex

sum jobsatdetailindex
sum jobsatposindex

gen blankspc1 = 0
gen blankspc2 = 0
gen blankspc3 = 0
label var blankspc1 "   "
label var blankspc2 "   "
label var blankspc3 "   "

sort raceML
by raceML: sum female if roleML==1
sum female if roleML != 1






 
	 
	 
*********************************************************************************************************************
*********************************************************************************************************************
** Regressions and Figures for RCFS paper 
*********************************************************************************************************************
*********************************************************************************************************************


*********************************************************************************************************************
** DATA section of paper - Descriptive stats Table 1
*********************************************************************************************************************

local list1   usaT europeT asia_ausT studentT facultyT nonfacresearcherT nonresearcherT femaleT
estpost tabstat `list1',  stat(mean n) col(stat)
esttab . using "$path/Table 1.rtf", cells("count mean(fmt(1)) ") collabels("N" "Percent") title("Table 1, Panel A: Demographic Characteristics of All Survey Respondents") ///
   nonumber noobs label  replace
   
estpost tab phd_yearML 
esttab . using "$path/Table 1.rtf", title("Panel B1- PhD Year of Survey Respondents")  cells("b pct(fmt(1)) ") collabels("N" "Percent") nolabel  noobs append

estpost tab phd_yearML if faculty==1
esttab . using "$path/Table 1.rtf" , title("Panel B2- PhD Year of Faculty")  cells("b pct(fmt(1)) ") collabels("N" "Percent") nolabel  noobs append

local list1   usaT europeT asia_ausT femaleT untenuredT corpfinT asstprcT behavT finintT hhT theoryT empiricalT topschoolT 
estpost tabstat `list1' if faculty==1,  stat(mean n) col(stat)
esttab . using "$path/Table 1.rtf", cells("count mean(fmt(1)) ") collabels("N" "Percent") title("Panel C: Demographic Characteristics Among Faculty") ///
   nonumber noobs label  append
   
estpost tab num_pub if faculty==1
esttab . using "$path/Table 1.rtf" , title("Panel D1- Num Pubs")  cells("b pct(fmt(1)) ") collabels("N" "Percent") nolabel  noobs append

estpost tab pub_top3fin if faculty==1
esttab . using "$path/Table 1.rtf" , title("Panel D2- Quality Pubs")  cells("b pct(fmt(1)) ") collabels("N" "Percent") nolabel  noobs append
   
estpost tab citations if faculty==1
esttab . using "$path/Table 1.rtf" , title("Panel D3- Citations")  cells("b pct(fmt(1)) ") collabels("N" "Percent") nolabel  noobs append
   
estpost tab seminvitebucket if faculty==1
esttab . using "$path/Table 1.rtf", title("Panel E1: Seminars")  cells("b pct(fmt(1)) ") collabels("N" "Percent") noobs append 

estpost tab keynote_invite if faculty==1
esttab . using "$path/Table 1.rtf", title("Panel E2: Keynotes")  cells("b pct(fmt(1)) ") collabels("N" "Percent") noobs append 

estpost tab teach_courses  if faculty==1
esttab . using "$path/Table 1.rtf", title("Panel F: Teaching Load")  cells("b pct(fmt(1)) ") collabels("N" "Percent") noobs append

 
**Extra desc stats
estpost tab $jobsat if faculty==1 
esttab . using "$path/Table IA xx.rtf", title("Panel XX: Job Satisfaction Index")  cells("b pct(fmt(1)) ") collabels("N" "Percent") noobs replace 
   
   

*********************************************************************************************************************
** DATA section of paper - Response bias
*********************************************************************************************************************


sort END_DATE

**First table on response bias: response date

drop sampt2
gen sampt2 = 1 if !missing(region_now3grps) & !missing(female) & !missing($jobsatdetailindex) & faculty==1 & !missing(citations) & citations !=7 & !missing(num_pub) & !missing(untenured) & !missing(topschool) & !missing(END_DATE) & !missing(corpfin)
sum discrim_pers_dumML01

sum jobsatdetailindex if sampt2==1



reg END_DATE discrim_pers_dumML01##female $contfac, cluster(region_now3grps)
eststo c2

reg END_DATE discrim_wit_dumML01##female $contfac, cluster(region_now3grps)
eststo c3

reg END_DATE c.$jobsat##female $contfac, cluster(region_now3grps)
eststo c4


reg respbucket1 discrim_pers_dumML01##female $contfac, cluster(region_now3grps)
eststo c5

reg respbucket1 discrim_wit_dumML01##female $contfac, cluster(region_now3grps)
eststo c6

reg respbucket1 c.$jobsat##female $contfac, cluster(region_now3grps)
eststo c7



reg END_DATE discrim_pers_dumML01##female $contfac if respdaybucket>1, cluster(region_now3grps)
eststo c8

reg END_DATE discrim_wit_dumML01##female $contfac if respdaybucket>1, cluster(region_now3grps)
eststo c9

reg END_DATE c.$jobsat##female $contfac if respdaybucket>1, cluster(region_now3grps)
eststo c10



local outpt "$path/Table 2.rtf" 

esttab  c2 c3 c4 c5 c6 c7 c8 c9 c10 using "`outpt'" , replace ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01)  modelwidth(6)  ///
	 title("Table 2: Response Time Bias ") ///
	 order(discrim_pers_dumML01 discrim_wit_dumML01 $jobsat female untenured  citations num_pub topschool    corpfin asstprc) drop(europe usa asia_aus) ///
	 mtitle( "Response Date" "Response Date" "Response Date" "Dummy: Respond Before Email Reminder" "Dummy: Respond Before Email Reminder" "Dummy: Respond Before Email Reminder" "Response Date (after first email reminder)" "Response Date (after first email reminder)" "Response Date (after first email reminder)") 
	 
	 


*********************************************************************************************************************
**Redo all results on subset of cases where respdaybucket>1*****************************************************************************************************- XX MAYBE ADD THEORY
*********************************************************************************************************************
/*
drop if respdaybucket==1

global graphs "C:\Users\ml3237\Dropbox\Climate Survey\Stata Programs_ML\Michelle output\wo respbucket1"
global path "C:\Users\ml3237\Dropbox\Climate Survey\Stata Programs_ML\Michelle output\wo respbucket1"
*/

*********************************************************************************************************************
**part 1 of paper =  career outcomes*****************************************************************************************************- XX MAYBE ADD THEORY
*********************************************************************************************************************


**Measures of job satisfaction by female - Figure 1 Panel A;

statplot dumjob_suprespect dumjob_workrespect dumjob_tknseriously dumjob_concerns2 dumjob_opportunities2 dumjob_workharder2  dumjob_inccolleagues dumjob_advancement    if researcher==1 & !missing(untenured), over(female)         asyvars bar(1, color(navy) lcolor(none) fintensity(*0.3)) bar(2, color(navy) lcolor(none) fintensity(*0.8)) yscale(r(0,80)) ylabel(0(20)80)  $attout ytitle("" )  legend(size(*.7)) legend(label(1 "Male")  label(2 "Female") size(*.9)) ytitle("Percent Respondents")
*graph save mygraph1, replace
graph export "$graphs/Figure 1a.pdf", replace

**Histogram of job satisfaction index - Figure 1 Panel B
   
twoway (histogram $jobsat if faculty==1 & female !=1, start(8) width(2) lcolor(none) fcolor(navy) fintensity(*0.3))  ///
	   (histogram $jobsat if faculty==1 & female==1,  start(8) width(2) lcolor(navy) fcolor(none))  , ///
	   legend(order(1 "Male" 2 "Female") size(*.8))	   
graph export "$graphs/Figure 1b.pdf", replace




twoway histogram $jobsat if faculty==1, discrete  percent lcolor(none) fcolor(navy) fintensity(*0.5) xtitle("Job Satisfaction Index") start(8) xlabel(8(8)48)
graph export "$graphs/Figure 1b.pdf", replace




**Measures of job satisfaction by female - WITHOUT RESPBUCKET1, FOR ROBUSTNESS;

statplot dumjob_suprespect dumjob_workrespect dumjob_tknseriously dumjob_concerns2 dumjob_opportunities2 dumjob_workharder2  dumjob_inccolleagues dumjob_advancement if researcher==1  & !missing(untenured) & respbucket1 !=1, over(female)         asyvars bar(1, color(navy) fintensity(*0.3)) bar(2, color(navy) fintensity(*0.8)) yscale(r(0,80)) ylabel(0(20)80)  $attout ytitle("" )  legend(size(*.7)) legend(label(1 "Male")  label(2 "Female") size(*.9)) ytitle("Percent Respondents")
graph export "$graphs/IA Figure 1_wo response bucket 1.pdf", replace







*********************************************************************************************************************
**Part 2 of paper: How do each of the 3 factors (preferences, discrim, structure work) vary by gender
*********************************************************************************************************************

*********************************************************************************************************************
**Table 3: Hetergeneity of Preferences is the first factor*****************************************************************************************************- XX MAYBE ADD THEORY
*********************************************************************************************************************



foreach x in power stimulation security  benevolence_a  universalism achievement selfdirection   hedonism conformity tradition     {

reg c`x' $contfac if drop != 1 & roleML==2 & citations !=7, cluster(region_now3grps)
eststo r`x'
    
}

local outpt "$path/Table 3.rtf" 

esttab rachievement rselfdirection rconformity rtradition rsecurity runiversalism  rbenevolence_a rstimulation  rpower rhedonism         using "`outpt'" , replace ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01) modelwidth(5) drop(europe usa asia_aus)  ///
	 title("Table 3: Heterogeneity of Preferences") ///
	 mtitle(    "Achievement"  "Self-direction"     "Conformity" "Tradition" "Security"   "Universalism" "Benevolence" "Stimulation" "Wealth" "Hedonism" )




**Effects within fields

foreach field in corpfin asstprc {

foreach x in power stimulation security  benevolence_a  universalism achievement selfdirection   hedonism conformity tradition     {

reg c`x'  $contfac if drop != 1 & roleML==2 & citations !=7 & `field'==1, cluster(region_now3grps)
eststo r`x'
    
}

local outpt "$path/Table 3_`field'.rtf" 

esttab rachievement rselfdirection rconformity rtradition rsecurity runiversalism  rbenevolence_a rstimulation  rpower rhedonism  using  "`outpt'" , replace ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01)  modelwidth(5) ///
	 title("Table Internet Appendix Table XX: Heterogeneity of Preferences, within Subfield of `field' ") drop(europe usa asia_aus corpfin asstprc) ///
	 mtitle(  "Achievement"  "Self-direction"     "Conformity" "Tradition" "Security"   "Universalism" "Benevolence" "Stimulation" "Wealth" "Hedonism")
	 
}	 
	 
	 
**Within women*****************************

foreach x in power stimulation security  benevolence_a  universalism achievement selfdirection   hedonism conformity tradition     {

reg c`x'  $contfac if drop != 1 & roleML==2 & citations !=7 & female==1, cluster(region_now3grps)
eststo r`x'
    
}

local outpt "$path/Table 3_females.rtf" 

esttab rachievement rselfdirection rconformity rtradition rsecurity runiversalism  rbenevolence_a rstimulation  rpower rhedonism    using "`outpt'" , replace ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01)  modelwidth(5) ///
	 title("Table Internet Appendix Table XX: Heterogeneity of Preferences, within Women " ) drop(europe usa asia_aus female) ///
	 mtitle(  "Achievement"  "Self-direction"     "Conformity" "Tradition" "Security"   "Universalism" "Benevolence" "Stimulation" "Wealth" "Hedonism")	 


**Descriptive Stats for IA

local list1a  achievement  selfdirection  conformity  tradition security   universalism  benevolence_a  stimulation power   hedonism   
local list1b  cachievement cselfdirection cconformity ctradition csecurity cuniversalism cbenevolence_a cstimulation cpower chedonism  
estpost tabstat `list1a' if faculty==1,  stat(mean n) col(stat)
esttab . using "$path/Table IA_pref vars.rtf", cells("count mean(fmt(1)) ") title("Table IA XX: Descriptive statistics on preferences"  "Panel A: Raw survey data") ///
   nonumber noobs label ///
   varlabel(achievement "Achievement" stimulation "Stimulation" security "Security" benevolence_a "Benevolence" universalism "Universalism" selfdirection "Self-direction"   hedonism "Hedonism" conformity "Conformity" tradition "Tradition" power "Wealth") replace
   
estpost tabstat `list1b' if faculty==1,  stat(mean n) col(stat)
esttab . using "$path/Table IA_pref vars.rtf", cells("count mean(fmt(1)) ") title("Panel B: De-meaned data as used in regressions") ///
   nonumber noobs label ///
   varlabel(cachievement "Achievement" cstimulation "Stimulation" csecurity "Security" cbenevolence_a "Benevolence" cuniversalism "Universalism" cselfdirection "Self-direction"   chedonism "Hedonism" cconformity "Conformity" ctradition "Tradition" cpower "Wealth") append
   

	 

	 



*********************************************************************************************************************
**Table 4: Structure of Work is the second factor
*********************************************************************************************************************


**Summarize time variables***************************************************************************************************************

   
**Descriptive stats

local list1  time_research2a  time_teaching2a time_teachingact2a time_service2a time_mtg2a time_email2a time_consult2a time_external2a  time_childcare2a time_social2a time_relax2a    time_exercise2a time_hobbies2a   time_volunteer2a time_sleep2
*local list1  time_research2  time_teaching2 time_teachingact2 time_service2 time_mtg2 time_email2 time_consult2 time_external2  time_childcare2 time_social2a time_relax2    time_exercise2a time_hobbies2   time_volunteer2a time_sleep2
estpost tabstat `list1' if faculty==1,  stat(mean n) col(stat)
esttab . using "$path/Table 4.rtf", cells("count mean(fmt(1)) ") title("Table 4: Allocation of Time Amongst People with a Single Structure of Work"  "Panel A: Average Time Spent in Work and Non-Work Activities") ///
   nonumber noobs label  replace


	 
**Table 4 - time allocations according to differnet types of school:  research-intensive vs less research-intensive (link to structure of work)

foreach d in time_research2a  time_teaching2a time_teachingact2a time_service2a time_mtg2a time_email2a time_external2a time_childcare2a time_nonwork2a {
	
	reg `d' female##topschool $contfac if citations !=7 , cluster(region_now3grps)
	eststo h1`d'
}


local outpt "$path/Table 4.rtf" 

esttab  h1time_research2a  h1time_teaching2a h1time_teachingact2a h1time_service2a h1time_mtg2a h1time_email2a h1time_childcare2a h1time_nonwork2a using "`outpt'" , append ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01) modelwidth(6) ///
	 mtitle("Research"  "Teaching" "Teaching prep" "Service"   "Mtgs w Colleagues" "Email" "Childcare" "Non-work Leisure") ///
	 title(" Panel B: Factors Related to Time Allocation") ///
	 drop(0.female 0.topschool 0.female*0.topschool 0.female*1.topschool  1.female*0.topschool female topschool europe asia_aus usa) ///
	 order(1.female 1.female*1.topschool topschool)
	 
	 
**Table 5 - family responsibilities***************************************************************************************************************

tab interruption

foreach d in children_under_18dum  childcare_precov   partnercaregiver eldercareML interruption   {
	
	reg `d' $contfac if citations !=7, cluster(region_now3grps)
	eststo h1`d'
}


local outpt "$path/Table 5.rtf" 

esttab  h1children_under_18dum  h1childcare_precov  h1partnercaregiver h1eldercareML h1interruption using "`outpt'" , replace ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01) modelwidth(6) drop(europe asia_aus usa) ///
	 mtitle("Have children under 18" "Percent childcare duties"  "Partner helps w childcare" "Elder care responsibilities" "Had interruption in career") ///
	 title("Table 5 - Family Responsibilities") 
	
	
**Desc stats for IA

estpost tab children_under_18dum if faculty==1
esttab . using "$path/Table IA_5.rtf", title("Descriptive statistics on family reponsibility variables" "Panel A: Children under 18")  cells("b pct(fmt(1)) ") collabels("N" "Percent") noobs replace 

estpost tab childcare_precov if faculty==1
esttab . using "$path/Table IA_5.rtf", title("Panel B: Percent childcare duties")  cells("b pct(fmt(1)) ") collabels("N" "Percent") noobs append 

estpost tab eldercareML if faculty==1
esttab . using "$path/Table IA_5.rtf", title("Panel C: Elder care responsibilities")  cells("b pct(fmt(1)) ") varlabels(`e(labels)', blist(Total "{hline @width}{break}")) varwidth(35) collabels("N" "Percent") noobs append 

estpost tab interruption if faculty==1
esttab . using "$path/Table IA_5.rtf", title("Panel D: Interruption(s) in career")  cells("b pct(fmt(1)) ") varlabels(`e(labels)', blist(Total "{hline @width}{break}")) varwidth(35) collabels("N" "Percent") noobs append 

	 
 

	 
*********************************************************************************************************************
**Table 6: DISCRIMINATION is the third factor
*********************************************************************************************************************

**RESEARCH FACULTY

sort female

local list1  discrim_pers_dumML01 discrim_wit_dumML01
estpost tabstat `list1' if !missing(untenured), by(female) stat(mean n) col(stat)
esttab . using "$path/Table6.rtf", cells("count mean(fmt(2)) ") title("Table 6, Panel A: Percent Respondents who have Experienced and Witnessed Discrimination - research faculty") ///
   nonumber  label  replace

local list1  discrim_pers_sexMLun discrim_pers_ageMLun discrim_pers_raceMLun discrim_pers_researchMLun discrim_pers_familyMLun discrim_pers_politicsMLun  discrim_pers_orientationMLun discrim_pers_religionMLun discrim_pers_disabilityMLun 
estpost tabstat `list1'  if !missing(untenured), by(female) stat(mean n) col(stat)
esttab . using "$path/Table6.rtf", cells("count mean(fmt(2)) ") title("Table 6, Panel B: Percent Respondents who have Experienced Each Type of Discrimination - research faculty") ///
   nonumber  label  append
   
local list1  discrim_wit_sexMLun discrim_wit_ageMLun discrim_wit_raceMLun discrim_wit_researchMLun discrim_wit_familyMLun discrim_wit_politicsMLun  discrim_wit_orientationMLun discrim_wit_religionMLun discrim_wit_disabilityMLun
estpost tabstat `list1'  if !missing(untenured), by(female) stat(mean n) col(stat)
esttab . using "$path/Table6.rtf", cells("count mean(fmt(2)) ") title("Table 6, Panel B: Percent Respondents who have Witnessed Each Type of Discrimination - research faculty") ///
   nonumber  label  append 
   
   
**NON-STUDENT SAMPLE   

local list1  discrim_pers_dumML01 discrim_wit_dumML01
estpost tabstat `list1' if student != 1, by(female) stat(mean n) col(stat)
esttab . using "$path/Table6.rtf", cells("count mean(fmt(2)) ") title("Table 6, Panel A: Percent Respondents who have Experienced and Witnessed Discrimination - NON-STUDENT sample") ///
   nonumber  label    append

local list1  discrim_pers_sexMLun discrim_pers_ageMLun discrim_pers_raceMLun discrim_pers_researchMLun discrim_pers_familyMLun discrim_pers_politicsMLun  discrim_pers_orientationMLun discrim_pers_religionMLun discrim_pers_disabilityMLun 
estpost tabstat `list1'  if student != 1 , by(female) stat(mean n) col(stat)
esttab . using "$path/Table6.rtf", cells("count mean(fmt(2)) ") title("Table 6, Panel B: Percent Respondents who have Experienced Each Type of Discrimination - NON-STUDENT sample") ///
   nonumber  label  append
   
local list1  discrim_wit_sexMLun discrim_wit_ageMLun discrim_wit_raceMLun discrim_wit_researchMLun discrim_wit_familyMLun discrim_wit_politicsMLun  discrim_wit_orientationMLun discrim_wit_religionMLun discrim_wit_disabilityMLun
estpost tabstat `list1' if student != 1 , by(female) stat(mean n) col(stat)
esttab . using "$path/Table6.rtf", cells("count mean(fmt(2)) ") title("Table 6, Panel B: Percent Respondents who have Witnessed Each Type of Discrimination - NON-STUDENT sample") ///
   nonumber  label  append  
   
   
   
** STUDENTS

local list1  discrim_pers_dumML01 discrim_wit_dumML01
estpost tabstat `list1' if student == 1, by(female) stat(mean n) col(stat)
esttab . using "$path/Table 6_studentsAndother.rtf", cells("count mean(fmt(2)) ") title("Table 6, Panel A: % Respondents who have Experienced and Witnessed Discrimination - students") ///
   nonumber  label    replace
   
**NON-ACADEMICS and non-research faculty

local list1  discrim_pers_dumML01 discrim_wit_dumML01
estpost tabstat `list1' if roleML==3 | roleML==4, by(female) stat(mean n) col(stat)
esttab . using "$path/Table 6_studentsAndother.rtf", cells("count mean(fmt(2)) ") title("Table 6, Panel A: % Respondents who have Experienced and Witnessed Discrimination - other") ///
   nonumber  label    append   
   
**Table 7, Panel A   

reg discrim_pers_dumML $contfac  if citations !=7, cluster(region_now3grps) 
eststo c1

reg discrim_wit_dumML  $contfac  if citations !=7, cluster(region_now3grps)
eststo c2

reg discrim_pers_dumML $contfac   if citations !=7 & respdaybucket>=2, cluster(region_now3grps) 
eststo c3

reg discrim_wit_dumML  $contfac if citations !=7 & respdaybucket>=2, cluster(region_now3grps)
eststo c4

reg discrim_pers_dumML $contfac   if citations !=7 & respdayemail==0, cluster(region_now3grps) 
eststo c5

reg discrim_wit_dumML  $contfac  if citations !=7 & respdayemail==0, cluster(region_now3grps)
eststo c6



local outpt "$path/Table 7.rtf" 

esttab  c1 c2 c3 c4 c5 c6 using "`outpt'" , replace ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01)  modelwidth(6) ///
	 title("Table 7 Panel A: Discrimination ") drop(europe asia_aus usa)  ///
	 mtitle("Experienced" "Witnessed" "Experienced_wo first resp bucket" "Witnessed_wo first resp bucket" "Experienced_wo email days" "Witnessed_wo email days")	 
	 

	 
	 
**TAble 7b: Types of experienced discrimination - Heckman 

foreach x in discrim_pers_sexML discrim_pers_ageML discrim_pers_raceML discrim_pers_researchML discrim_pers_familyML discrim_pers_politicsML  discrim_pers_orientationML discrim_pers_religionML discrim_pers_disabilityML  {
    
heckman `x'  $contfac   if citations !=7, select(discrim_pers_dumML = respbucket1  $contfac  ) twostep
eststo c`x'	
		
}

local outpt "$path/Table 7.rtf" 

esttab  cdiscrim_pers_sexML cdiscrim_pers_ageML cdiscrim_pers_raceML cdiscrim_pers_researchML cdiscrim_pers_familyML cdiscrim_pers_politicsML  cdiscrim_pers_orientationML cdiscrim_pers_religionML cdiscrim_pers_disabilityML using "`outpt'" , append ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01)  modelwidth(6) ///
	 title("Table 7 Panel B: Types of Experienced Discrimination, Heckman ") drop(europe asia_aus usa)  ///
	 mtitle("Sex" "Age" "Race" "Research" "Family" "Politics" "Orientation" "Religion" "Disability")
	 



	 
	 
	 
**Table 7 IA: Types of Witnessed Discrimination - ols wo first bucket, for IA	 

foreach x in discrim_wit_sexML discrim_wit_ageML discrim_wit_raceML discrim_wit_researchML discrim_wit_familyML discrim_wit_politicsML  discrim_wit_orientationML discrim_wit_religionML discrim_wit_disabilityML {
    
reg `x'  $contfac   if citations !=7 & respbucket1 !=1, cluster(region_now3grps)
eststo c`x'
		
}

local outpt "$path/IA Table 7C_wo respbucket1_For IA.rtf" 

esttab  cdiscrim_wit_sexML cdiscrim_wit_ageML cdiscrim_wit_raceML cdiscrim_wit_researchML cdiscrim_wit_familyML cdiscrim_wit_politicsML  cdiscrim_wit_orientationML cdiscrim_wit_religionML cdiscrim_wit_disabilityML using "`outpt'" , replace ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01)  modelwidth(6) drop(europe asia_aus usa) ///
	 title("Table 6b: Types of Witnessed Discrimination - Without first response bucket, for IA") ///
	 mtitle("Sex" "Age" "Race" "Research" "Family" "Politics" "Orientation" "Religion" "Disability")	 


	 


*********************************************************************************************************************
** Part 3 of paper: How is job satisfaction affected by 3 factors
*********************************************************************************************************************
	 
*********************************************************************************************************************
**Table 8: Heterogeneity in job satisfaction with and without 3 factors *********************************************************************************************   
*********************************************************************************************************************



**Table 8 for paper

reg $jobsat $contfac                                                                               if citations !=7, cluster(region_now3grps)
eststo e1
adjust female=1
adjust female=0


reg $jobsat $contfac                                      cachievement cselfdirection             if citations !=7, cluster(region_now3grps)
eststo e2
adjust female=1
adjust female=0


reg $jobsat $contfac                                                                  childdutiespre if citations !=7, cluster(region_now3grps)
eststo e3
adjust female=1
adjust female=0


reg $jobsat $contfac discrim_pers_dumML01 discrim_wit_dumML01                                         if citations !=7, cluster(region_now3grps)
eststo e4
adjust female=1
adjust female=0

reg $jobsat $contfac discrim_pers_dumML01 discrim_wit_dumML01 cachievement cselfdirection  childdutiespre    if citations !=7, cluster(region_now3grps)
eststo e5
adjust female=1
adjust female=0

local outpt "$path/Table 8.rtf" 

esttab   e1 e1a e1b e2 e3 e4 e5 using "`outpt'" , replace ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01) modelwidth(6) ///
	 order(female cachievement cselfdirection childdutiespre discrim_pers_dumML01 discrim_wit_dumML01  untenured  citations num_pub topschool    corpfin asstprc ) drop(europe asia_aus usa) ///
	 title("Table 8 - Heterogeneity in Job Satisfaction: Influence of Preferences, Structure of Work, and Bias") varlabels(childdutiespre "Child duties")	
	 

	 
	 
**(IA table) All job sat variables, with just female ******************************************************


foreach d in job_concernsrev job_workharderrev job_opportunitiesrev job_inccolleagues job_advancement job_suprespect job_tknseriously job_workrespect  {

reg `d' $contfac  if citations !=7, cluster(region_now3grps)
eststo e1`d'

}


	 
	 
	 
	 
**(IA table) All job sat variables, with  female, discrimination, preferences, and interruption variables ******************************************************

foreach d in job_concernsrev job_workharderrev job_opportunitiesrev job_inccolleagues job_advancement job_suprespect job_tknseriously job_workrespect  {

reg `d' $contfac $sourcedif if citations !=7, cluster(region_now3grps)
eststo e2`d'

}

local outpt "$path/IA Table 8 using components of job sat index.rtf" 

esttab   e1job_concernsrev e1job_workharderrev e1job_opportunitiesrev    e1job_inccolleagues e1job_advancement e1job_suprespect e1job_tknseriously e1job_workrespect  using "`outpt'" , replace ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01) modelwidth(6) drop(europe asia_aus usa) ///
	 mtitle("Comfort raising issues" "Equal effort required" "Equal opportunities" "Colleagues include me in opps" "Standards applied equally" "Supervisor respects me" "Others take my views seriously" "My work is respected by my peers") ///
	 title("Internet Appendix Table XX: Components of Job Satisfaction Index Panel A: Individual and Institutional Demographic Characteristics ")
	 
	 
esttab   e2job_concernsrev e2job_workharderrev e2job_opportunitiesrev    e2job_inccolleagues e2job_advancement e2job_suprespect e2job_tknseriously e2job_workrespect  using "`outpt'" , append ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01) modelwidth(6) drop(europe asia_aus usa) ///
	 mtitle("Comfort raising issues" "Equal effort required" "Equal opportunities" "Colleagues include me in opps" "Standards applied equally" "Supervisor respects me" "Others take my views seriously" "My work is respected by my peers") ///
	 order(female cachievement cselfdirection childdutiespre  discrim_pers_dumML01 discrim_wit_dumML01 )  ///
	 title("Panel B: Accounting for Preferences, Structure of Work, and Preferences")
	 
	 
**Desc stats on job sat for IA, T8 vars

local list1  job_concernsrev job_workharderrev job_opportunitiesrev job_inccolleagues job_advancement job_suprespect job_tknseriously job_workrespect jobsatdetailindex
estpost tabstat `list1' if faculty==1,  stat(p25 p50 p75 mean n) col(stat)
esttab . using "$path/Table IA T8.rtf", cells("count p25(fmt(2)) p50(fmt(2)) p75(fmt(2)) mean(fmt(2)) ") title("Table IA XX: Job satisfaction variables ") ///
   varlabel(job_concernsrev "Comfort raising issues" job_workharderrev "Equal effort required" job_opportunitiesrev "Equal opportunities" job_inccolleagues "Colleagues include me in opps" job_advancement "Standards applied equally" job_suprespect "Supervisor respects me" job_tknseriously "Others take my views seriously"  job_workrespect "My work is respected by my peers" jobsatdetailindex "Job satisfaction index") ///
   nonumber  label  replace    
   	 
	 

	 
*********************************************************************************************************************
** Part 4 of paper:  How does it matter (free expresson, asking questions, avoidance, covid, new project).
** do we want to focus on most impt or carry all variables through
*********************************************************************************************************************
	 
**Table 9 - avoiding opportunities	 
sum avoid_notapplyML avoid_leftpostML avoid_notresearchML if faculty==1 & citations !=7 & !missing(untenured) & !missing(female) & !missing(region_now3grps) & !missing(corpfin) & !missing(num_pub) & !missing(topschool) & !missing(citations)


**Calculate std dev of dept var, for econ sigce calcs

	
reg avoid_notapplyML    $contfac                 if citations !=7, cluster(region_now3grps)
eststo e1
adjust female=1
adjust female=0

reg avoid_leftpostML    $contfac                 if citations !=7, cluster(region_now3grps)
eststo e2
adjust female=1
adjust female=0

reg avoid_notresearchML  $contfac                if citations !=7, cluster(region_now3grps)
eststo e3
adjust female=1
adjust female=0

reg avoid_notapplyML     $contfac $jobsat if citations !=7, cluster(region_now3grps)
eststo e4
adjust female=0
adjust female=1

reg avoid_leftpostML     $contfac  $jobsat if citations !=7, cluster(region_now3grps)
eststo e5
adjust female=0
adjust female=1

reg avoid_notresearchML   $contfac  $jobsat if citations !=7, cluster(region_now3grps)
eststo e6
adjust female=0
adjust female=1




reg avoid_notapplyML      $contfac   $sourcedif if citations !=7, cluster(region_now3grps)
eststo e7
adjust female=0
adjust female=1
adjust discrim_pers_dumML01=0
adjust discrim_pers_dumML01=1

reg avoid_leftpostML       $contfac  $sourcedif  if citations !=7, cluster(region_now3grps)
eststo e8
adjust female=0
adjust female=1
adjust discrim_pers_dumML01=0
adjust discrim_pers_dumML01=1

reg avoid_notresearchML    $contfac  $sourcedif  if citations !=7, cluster(region_now3grps)
eststo e9
adjust female=0
adjust female=1
adjust discrim_pers_dumML01=0
adjust discrim_pers_dumML01=1

sum avoid_notapplyML avoid_leftpostML avoid_notresearchML

local outpt "$path/Table 9.rtf" 

esttab e1 e2 e3 e4 e5 e6 e7 e8 e9 using "`outpt'" , replace ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01) modelwidth(6) drop(europe asia_aus usa) ///
	 order(female $jobsat cachievement cselfdirection childdutiespre discrim_pers_dumML01 discrim_wit_dumML01   untenured  citations num_pub topschool    corpfin asstprc ) ///
	 title("Table 9 - Avoiding opportunities") 
	 
	 
	 
**Table 10 - ask questions	 
	 
reg QUES_SEM   $contfac                 if citations !=7, cluster(region_now3grps)
eststo e1
adjust female=0
adjust female=1

reg QUES_CONF  $contfac                 if citations !=7, cluster(region_now3grps)
eststo e2
adjust female=0
adjust female=1

reg QUES_SEM   $contfac  $jobsat if citations !=7, cluster(region_now3grps)
eststo e3
adjust female=0
adjust female=1

reg QUES_CONF  $contfac  $jobsat if citations !=7, cluster(region_now3grps)
eststo e4
adjust female=0
adjust female=1

reg QUES_SEM   $contfac $sourcedif      if citations !=7, cluster(region_now3grps)
eststo e5
adjust female=0
adjust female=1

reg QUES_CONF  $contfac  $sourcedif     if citations !=7, cluster(region_now3grps)
eststo e6
adjust female=0
adjust female=1

local outpt "$path/Table 10.rtf" 

esttab e1 e2 e3 e4 e5 e6 using "`outpt'" , replace ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01) modelwidth(6) drop(europe asia_aus usa) ///
	 order(female $jobsat cachievement cselfdirection childdutiespre discrim_pers_dumML01 discrim_wit_dumML01   untenured  citations num_pub topschool    corpfin asstprc ) ///
	 title("Table 10 - Academic Discourse") 	
	 
**Desc stats on job sat for IA

local list1  QUES_SEM QUES_CONF
sum `list1'
estpost tabstat `list1' ,  stat(p25 p50 p75 mean n) col(stat)
esttab . using "$path/Table IA T8.rtf", cells("count p25(fmt(2)) p50(fmt(2)) p75(fmt(2)) mean(fmt(2)) ") title("Table IA XX: Job satisfaction variables ") ///
   varlabel(job_concernsrev "Comfort raising issues" job_workharderrev "Equal effort required" job_opportunitiesrev "Equal opportunities" job_inccolleagues "Colleagues include me in opps" job_advancement "Standards applied equally" job_suprespect "Supervisor respects me" job_tknseriously "Others take my views seriously"  job_workrespect "My work is respected by my peers" jobsatdetailindex "Job satisfaction index") ///
   nonumber  label  replace   	 
	 
**Table 11 - free expression of ideas	 
	 
reg scifree_dept      $contfac                    if citations !=7, cluster(region_now3grps)
eststo e1


reg scifree_conf  $contfac                    if citations !=7, cluster(region_now3grps)
eststo e2

reg scifree_editorial $contfac                   if citations !=7, cluster(region_now3grps)
eststo e3


reg scifree_dept      $contfac    $jobsat if citations !=7, cluster(region_now3grps)
eststo e4
sum $jobsat scifree_dept if e(sample)==1

reg scifree_conf      $contfac    $jobsat if citations !=7, cluster(region_now3grps)
eststo e5
sum $jobsat scifree_conf if e(sample)==1

reg scifree_editorial $contfac    $jobsat if citations !=7, cluster(region_now3grps)
eststo e6
sum $jobsat scifree_editorial if e(sample)==1

reg scifree_dept      $contfac  $sourcedif       if citations !=7, cluster(region_now3grps)
eststo e7

reg scifree_conf      $contfac $sourcedif        if citations !=7, cluster(region_now3grps)
eststo e8

reg scifree_editorial $contfac  $sourcedif       if citations !=7, cluster(region_now3grps)
eststo e9


local outpt "$path/Table 11.rtf" 

esttab e1 e2 e3 e4 e5 e6 e7 e8 e9  using "`outpt'" , replace ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01) modelwidth(6) drop(europe asia_aus usa) ///
	 order(female  $jobsat cachievement cselfdirection childdutiespre discrim_pers_dumML01 discrim_wit_dumML01  untenured  citations num_pub topschool    corpfin asstprc ) ///
	 mtitle("Dept" "Confs" "Editorial Process" "Dept" "Confs" "Editorial Process"  "Dept"   "Confs"  "Editorial Process") ///
	 title("Table 11 - Do people feel that field encourages free expression and exchange of scientific ideas") 

	 


**Desc stats on job sat for IA T9 - 11 vars

local list1  avoid_notapplyML avoid_leftpostML avoid_notresearchML
sum `list1'
estpost tabstat `list1' if faculty==1,  stat(mean n) col(stat)
esttab . using "$path/Table IA T9_11.rtf", cells("count mean(fmt(2)) ") title("Table IA Descriptive stats on variables related to costs of low job satisfaction. Panel A: Avoiding Opportunities ") ///
   nonumber  label  replace	 
   
    
estpost tab QUES_SEM if faculty==1
esttab . using "$path/Table IA T9_11.rtf" , title("Panel B1: Academic Discourse")  cells("b pct(fmt(1)) ") collabels("N" "Percent") nolabel  noobs append

estpost tab QUES_CONF if faculty==1
esttab . using "$path/Table IA T9_11.rtf" , title("Panel B2: Academic Discourse")  cells("b pct(fmt(1)) ") collabels("N" "Percent") nolabel  noobs append
	 	 
estpost tab scifree_dept if faculty==1
esttab . using "$path/Table IA T9_11.rtf" , title("Panel C1: Opinions regarding exchange of ideas")  cells("b pct(fmt(1)) ") collabels("N" "Percent") nolabel  noobs append

estpost tab scifree_conf if faculty==1
esttab . using "$path/Table IA T9_11.rtf" , title("Panel C2: Opinions regarding exchange of ideas")  cells("b pct(fmt(1)) ") collabels("N" "Percent") nolabel  noobs append

estpost tab scifree_editorial if faculty==1
esttab . using "$path/Table IA T9_11.rtf" , title("Panel C3: Opinions regarding exchange of ideas")  cells("b pct(fmt(1)) ") collabels("N" "Percent") nolabel  noobs append

	 
	 
*********************************************************************************************************************
** Part 5 of paper:  What to do (authority address, employer acocmodation, seminars, mentorship)
**  do we want to focus on most impt or carry all variables through
*********************************************************************************************************************

tab interruption_accom_enc if interruption !=1 /*34 no, 109 yes, 143 total */
tab interruption_accom	/*163 yes, 109 no, total 272 */
tab interruption_accom_rev	/*163 yes, 109 no, total 272 */
tab mentorconnect


	 
**Table 12: is job satisfaction higher if ...

gen mentordeptdum = 0 if mentor_dept ==1
replace mentordeptdum = 1 if mentor_dept==2

gen mentorgenderdum = 0 if mentor_gender==1
replace mentorgenderdum = 1 if mentor_gender==2


reg $jobsat discrim_authaddress_dumML   $sourcedif  $contfac if citations !=7 , cluster(region_now3grps)
eststo e1	

reg $jobsat interruption_accom_rev          $sourcedif  $contfac if citations !=7 & interruption>=2 & !missing(interruption), cluster(region_now3grps)
eststo e2	 
	 
reg $jobsat mentor                      $sourcedif  $contfac if citations !=7, cluster(region_now3grps)
eststo e3	

reg $jobsat mentor mentordeptdum          $sourcedif  $contfac if citations !=7 , cluster(region_now3grps)
eststo e4

reg $jobsat mentor mentorassigned        $sourcedif  $contfac if citations !=7 , cluster(region_now3grps)
eststo e5

reg $jobsat mentor mentorgenderdum        $sourcedif  $contfac if citations !=7 , cluster(region_now3grps)
eststo e6


local outpt "$path/Table 12.rtf" 

esttab e1 e2 e3 e4 e5 e6 using "`outpt'" , replace ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01) modelwidth(6) drop(europe asia_aus usa) ///
	 order(discrim_authaddress_dumML interruption_accom_rev mentor mentor_dept mentorassigned mentor_gender discrim_pers_dumML01 discrim_wit_dumML01  cachievement cselfdirection childdutiespre  $contt7 ) ///
	 title("Table 12 - Effects of Authoritative Action and Mentorship on Job Satisfaction") ///
	 varlabels(discrim_authaddress_dumML "Authority addressed discrimination" interruption_accom_rev "Employer made and encouraged accommodation" mentor "Have mentor" mentor_dept "Have mentor within dept" mentor_gender "Have mentor of same gender" childdutiespre "Child duties") 

	 
**Desc stats on job sat for IA T12 vars

local list1  discrim_authaddress_dumML interruption_accom_rev  
sum `list1'
estpost tabstat `list1' if faculty==1,  stat(mean n) col(stat)
esttab . using "$path/Table IA T12.rtf", cells("count mean(fmt(4)) ") title("Table IA Descriptive stats on variables related to authoritative action and senior leadership ") ///
   varlabel(discrim_authaddress_dumML "Authority addressed discrimination") ///
   nonumber  label  replace	 
   
estpost tab mentor if faculty==1
esttab . using "$path/Table IA T12.rtf" , title("Mentorship")  cells("b pct(fmt(1)) ") collabels("N" "Percent") nolabel  noobs append
    
local list1   mentordeptdum mentorassigned mentorgenderdum
sum `list1'
estpost tabstat `list1' if faculty==1,  stat(mean n) col(stat)
esttab . using "$path/Table IA T12.rtf", cells("count mean(fmt(4)) ") title("Table IA Descriptive stats on variables related to authoritative action and senior leadership ") ///
   varlabel( mentordeptdum "Have mentor within department" mentorgenderdum "Have mentor of same gender") ///
   nonumber  label  append	 
   
  
	 
**Table 13: is job satisfaction higher if higher female involvement in dept

tab last_offer
tab femaleaccepted


reg $jobsat speakerfemaledum $sourcedif  $contfac if citations !=7 & female==1, cluster(region_now3grps)
eststo e1	

reg $jobsat lastofferfemale $sourcedif $contfac if citations !=7 & last_offer !=1 & female==1, cluster(region_now3grps)
eststo e2	 
	 
reg $jobsat femaleaccepted $sourcedif  $contfac if citations !=7 & female==1, cluster(region_now3grps)
eststo e3

reg $jobsat speakerfemaledum $sourcedif  $contfac if citations !=7 & female==0, cluster(region_now3grps)
eststo e4	

reg $jobsat lastofferfemale $sourcedif $contfac if citations !=7 & female==0 & last_offer !=1, cluster(region_now3grps)
eststo e5	 
	 
reg $jobsat femaleaccepted $sourcedif  $contfac if citations !=7  & female==0, cluster(region_now3grps)
eststo e6	



local outpt "$path/Table 13.rtf" 

esttab e1 e2 e3 e4 e5 e6 using "`outpt'" , replace ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01) modelwidth(6) ///
	 order(speakerfemaledum lastofferfemale femaleaccepted  ) drop(europe asia_aus usa female) ///
	 title("Table 13 - Effects of Female Seminar Speakers and Job Offers on Job Satisfaction ") ///
	 mtitle("Females" "Females" "Females" "Males" "Males" "Males") ///
	 varlabels(childdutiespre "Child duties" speakerfemaledum "Female seminar speaker" lastofferfemale "Job offer to female" femaleaccepted "Accepted offer to female ")
	 
	 	 


	 
	 
** TAble 14:  Are women more likely to receive offers?

**percent of females
tab female

**percent of females among untenured##female
tab female if untenured==1


**percent of females w phd 2016 - 2020
tab female if phd_year_suppressed==15	 

**percent of females among students on job mkt last year
tab female if !missing(job_jobmkt_no) | !missing(job_jobmkt_pers_exp) | !missing(job_jobmkt_witnessed)
	 
tab job_jobmkt_no
tab job_jobmkt_pers_exp
tab job_jobmkt_witnessed	 
	 
**percent females among students*/
tab female if student==1
	 
	 
**percent offers made to females: categories 1, 2, 3 = 20 + 24 + 5 = 49%
tab last_offer 	 
	 
	 
sort female	 
	 
by female: tab unsolicited_offer	 
by female: tab unsolicited_discuss
by female: tab unsolicited_counter





reg unsolicited_discussdum          $contfac if citations !=7 , cluster(region_now3grps)
eststo e1	

reg unsolicited_offerdum            $contfac if citations !=7 , cluster(region_now3grps)
eststo e2	

reg unsolicited_counter          $contfac if citations !=7 , cluster(region_now3grps)
eststo e3	

reg countergood                  $contfac if citations !=7 , cluster(region_now3grps)
eststo e4	

reg unsolicited_discussdum $sourcedif $contfac if citations !=7 , cluster(region_now3grps)
eststo e5

reg unsolicited_offerdum $sourcedif $contfac if citations !=7 , cluster(region_now3grps)
eststo e6	

reg unsolicited_counter $sourcedif $contfac if citations !=7 , cluster(region_now3grps)
eststo e7	

reg countergood         $sourcedif $contfac if citations !=7 , cluster(region_now3grps)
eststo e8
	 

local outpt "$path/Table 14.rtf" 

esttab e1 e2  e4 e5 e6  e8 using "`outpt'" , replace ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01) modelwidth(6) ///
	 order( female discrim_pers_dumML01 discrim_wit_dumML01  cachievement cselfdirection childdutiespre) ///
	 title("Table 14 - Female likelihood of getting outside offer ") drop(europe asia_aus usa) ///
	 mtitle("Approached to discuss possible job offer" "Received unsolicited offer" "Received competitive counteroffer" "Approached to discuss possible job offer" "Received unsolicited offer"  "Received competitive counteroffer" ) varlabels(childdutiespre "Child duties")
	 
	 
tab unsolicited_discussdum
tab unsolicited_offerdum
tab unsolicited_counter
tab countergood

**IA Desc stats for variables in Tables 13 and 14

local list1  speakerfemaledum lastofferfemale  femaleaccepted
sum `list1'
estpost tabstat `list1' if faculty==1,  stat(mean n) col(stat)
esttab . using "$path/Table IA T13_14.rtf", cells("count mean(fmt(4)) ") title("Table IA Descriptive stats on female seminar speakers and offers ") ///
varlabel(speakerfemaledum "Female seminar speaker" lastofferfemale "Job offer to female" femaleaccepted "Accepted offer to female") ///
    nonumber  label  replace	 

local list1  unsolicited_discussdum unsolicited_offerdum  countergood
sum `list1'
estpost tabstat `list1' if faculty==1,  stat(mean n) col(stat)
esttab . using "$path/Table IA T13_14.rtf", cells("count mean(fmt(4)) ") title("Table IA Descriptive stats on female seminar speakers and offers ") ///
varlabel(unsolicited_discussdum "Approached to discuss possible job offer" unsolicited_offerdum "Received unsolicited offer" countergood "Received competitive counteroffer") ///
    nonumber  label  append	 
 
 
	 


	 
**Table 15: Do sources of childcare contribute to job satisfaction

** Panel A: descriptive stats

sort female

global list1 chldcare_partnerML chldcare_caregiverML chldcare_onoffML  childcare1

estpost tabstat $list1 if faculty==1, by(female) stat(mean n) col(stat)
esttab . using "$path/Table 15.rtf", cells("count mean(fmt(3)) ") title("Table 15 - Sources of Childcare Panel A: Percent of respondents who use various sources of childcare") ///
   nonumber noobs label  replace
   
ttest chldcare_partnerML, by(female)   
ttest chldcare_caregiverML, by(female)   
ttest chldcare_onoffML, by(female)   
ttest childcare1, by(female)   


**Panel B: regressions of job satisfaction
/*
gen chldcare_ext = 1 if chldcare_onoffML==1 | chldcare_caregiverML==1
replace chldcare_ext = 0 if chldcare_onoffML==0 & chldcare_caregiverML==0
*/
reg jobsatdetailindex chldcare_caregiverML    $contfac if citations !=7 & female==1, cluster(region_now3grps)
eststo e1	

reg jobsatdetailindex chldcare_onoffML   $contfac if citations !=7 & female==1, cluster(region_now3grps)
eststo e2	 
	 
reg jobsatdetailindex chldcare_partnerML    $contfac if citations !=7 & female==1, cluster(region_now3grps)
eststo e3

reg jobsatdetailindex chldcare_caregiverML     $contfac if citations !=7 & female==0, cluster(region_now3grps)
eststo e4	

reg jobsatdetailindex chldcare_onoffML     $contfac if citations !=7 & female==0 , cluster(region_now3grps)
eststo e5	 
	 
reg jobsatdetailindex chldcare_partnerML   $contfac if citations !=7  & female==0, cluster(region_now3grps)
eststo e6	
sum chldcare_onoffML

local outpt "$path/Table 15.rtf" 

esttab e1 e2 e3 e4 e5 e6 using "`outpt'" , append ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01) modelwidth(6) ///
	 order(chldcare_caregiverML chldcare_onoffML  chldcare_partnerML)  ///
	 title("Panel B:  Do Sources of Childcare Contribute to Job Satisfaction") ///
	 mtitle("Females" "Females" "Females" "Males" "Males" "Males") 
	 

 
**********************************************************************************************************************************************
**  Final set of evidence - people outside of academia	 
**********************************************************************************************************************************************
	 
*local samp16a if roleML==3 | roleML==4	
global samp16a if (roleML==3 | roleML==4) & employer_suppressed !=1

tab female `samp16a'


** Panel A: 3 factors********************************

**preferences
	 
foreach x in achievement selfdirection  {

reg c`x' $contoth $samp16a, cluster(region_now3grps)
eststo f1`x'
    
}

**Time allocations

reg time_childcare_non_acad  $contoth  $samp16a, cluster(region_now3grps)
eststo ftime_childcare_non_acad

reg childcare_precov $contoth  $samp16a, cluster(region_now3grps) 
eststo f2childcare


**Discrimination
	 
reg discrim_pers_sexMLun  $contoth   $samp16a, cluster(region_now3grps) 
eststo f3discrim_pers_sexMLun	
		

	 
**  Do 3 factors affect Job Satisfaction********************************	 


reg $jobsat $contoth discrim_pers_sexMLun  cachievement cselfdirection  childdutiespre $samp16a, cluster(region_now3grps)
eststo b2

	 
** Costs of lower job satisfaction********************************	 
	 

reg QUES_CONF discrim_pers_sexMLun cachievement cselfdirection childdutiespre $contoth $samp16a, cluster(region_now3grps)
eststo c2



 
	 
**

local outpt "$path/Table 16.rtf" 

esttab f1achievement f1selfdirection ftime_childcare_non_acad f2childcare ftime_nonwork_nonacademic f3discrim_pers_sexMLun       using "`outpt'" , replace ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01) modelwidth(5) drop(europe usa asia_aus)  ///
	 title("Table 16 - Non-Academics. Panel A: Preferences, Structure of Work, and Discrimination") ///
	 mtitle(    "Achievement"  "Self-direction" "Time on Childcare" "Pct Childcare Duties" "Time on Non-work Leisure" "Discrimination on Base of Sex"  )	 

esttab   b2  c2 using "`outpt'" , append ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01) modelwidth(6) ///
	 order(female discrim_pers_dumML01  cachievement cselfdirection childdutiespre   ) drop(europe asia_aus usa) ///
	 title("Panel B - Effects of Preferences, Structure of Work, and Bias")  varlabels(childdutiespre "Child duties" ) 
	 
esttab d1 d3 e1 e4 using "`outpt'" , append ///
     label nonumbers onecell nogap    se ar2 star(* 0.10 ** 0.05 *** 0.01) modelwidth(6) ///
	 order(discrim_authaddress_dumML mentor speakerfemaledum   ) drop(europe asia_aus usa female) ///
	 title("Panel C - Effects of Authoritative Actions ") ///
	 mtitle("All Respondents" " All Respondents" "Females" "Males" ) ///
	 varlabels(childdutiespre "Child duties" speakerfemaledum "Female seminar speaker" lastofferfemale "Job offer to female" femaleaccepted "Accepted offer to female " ///
	discrim_authaddress_dumML "Authority addressed discrimination" mentor "Have mentor" childdutiespre "Child duties")

	 
	

	
	
	
	
	

